aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/moon/roles
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/moon/roles')
-rwxr-xr-xplugins/moon/roles/moon/handlers/main.yml15
-rw-r--r--plugins/moon/roles/moon/tasks/main.yml11
-rw-r--r--plugins/moon/roles/moon/tasks/moon.yml230
-rwxr-xr-xplugins/moon/roles/moon/templates/compute.j252
-rwxr-xr-xplugins/moon/roles/moon/templates/ifcfg-br-mgmt7
-rwxr-xr-xplugins/moon/roles/moon/templates/ifcfg-br-storage8
-rwxr-xr-xplugins/moon/roles/moon/templates/ifcfg-br-vlan11
-rwxr-xr-xplugins/moon/roles/moon/templates/ifcfg-br-vxlan8
-rwxr-xr-xplugins/moon/roles/moon/templates/ifcfg-if.storage4
-rwxr-xr-xplugins/moon/roles/moon/templates/ifcfg-if.vxlan4
-rwxr-xr-xplugins/moon/roles/moon/templates/sources.list.lab7
-rwxr-xr-xplugins/moon/roles/moon/templates/sources.list.official36
-rwxr-xr-xplugins/moon/roles/moon/vars/main.yml10
13 files changed, 403 insertions, 0 deletions
diff --git a/plugins/moon/roles/moon/handlers/main.yml b/plugins/moon/roles/moon/handlers/main.yml
new file mode 100755
index 00000000..ab2a090b
--- /dev/null
+++ b/plugins/moon/roles/moon/handlers/main.yml
@@ -0,0 +1,15 @@
+##############################################################################
+## Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+---
+- name: restart network service
+ shell: "ifconfig eth0 down && ifconfig eth0 up && \
+ /sbin/ifdown -a && \
+ /sbin/ifup --ignore-errors -a"
+
+- name: restart nfs service
+ service: name=nfs-kernel-server state=restarted
diff --git a/plugins/moon/roles/moon/tasks/main.yml b/plugins/moon/roles/moon/tasks/main.yml
new file mode 100644
index 00000000..91283129
--- /dev/null
+++ b/plugins/moon/roles/moon/tasks/main.yml
@@ -0,0 +1,11 @@
+##############################################################################
+# Copyright (c) 2016-2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+---
+- include: moon.yml
+ when: moon is defined and moon == "Enable" and ansible_os_family == "Debian"
diff --git a/plugins/moon/roles/moon/tasks/moon.yml b/plugins/moon/roles/moon/tasks/moon.yml
new file mode 100644
index 00000000..22327007
--- /dev/null
+++ b/plugins/moon/roles/moon/tasks/moon.yml
@@ -0,0 +1,230 @@
+#############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+---
+- name: rm pip.conf
+ file:
+ path: /root/.pip/pip.conf
+ state: absent
+
+- name: configure network
+ template:
+ src: compute.j2
+ dest: /etc/network/interfaces
+ notify:
+ - restart network service
+
+- meta: flush_handlers
+
+- name: check apt source
+ shell: "ping -c 2 {{ LOCAL_REPOSITORY_IP }} > /dev/null"
+ register: checkresult
+ ignore_errors: "true"
+
+- name: change sources list(apt)
+ template:
+ src: sources.list.lab
+ dest: /etc/apt/sources.list
+ when: checkresult.rc == 0
+
+- name: change sources list(apt)
+ template:
+ src: sources.list.official
+ dest: /etc/apt/sources.list
+ when: checkresult.rc != 0
+
+- name: check docker.list stat
+ stat:
+ path: /etc/apt/sources.list.d/docker.list
+ register: stat_result
+
+# [WARNING]: Consider using get_url or uri module rather than running wget
+- name: install docker
+ remote_user: root
+ shell: wget -qO- https://get.docker.com/ | sh
+ when: stat_result.stat.exists == False
+
+- name: remove conflict packages
+ remote_user: root
+ action: "{{ ansible_pkg_mgr }} name={{ item }} state=absent"
+ with_items:
+ - python3-pkg-resources
+
+- name: install dependent packages
+ remote_user: root
+ action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+ with_items:
+ - git
+ - python3-dev
+ - python3-pip
+ - python3-venv
+ - python3-setuptools
+
+- name: make ubuntu dir
+ file:
+ path: /home/ubuntu
+ state: directory
+ mode: 0755
+
+- name: check moon code dir exists
+ stat:
+ path: /home/ubuntu/moon
+ register: stat_result
+
+- name: fetch moon source code
+ shell: git clone https://git.opnfv.org/moon /home/ubuntu/moon
+ when: stat_result.stat.exists == False
+
+- name: create moon etc conf
+ remote_user: root
+ file:
+ src: /home/ubuntu/moon/moonv4/moon_orchestrator/conf
+ dest: /etc/moon
+ state: link
+
+- name: configure moon.conf
+ lineinfile:
+ dest: /etc/moon/moon.conf
+ regexp: '{{ item.regexp }}'
+ line: '{{ item.line }}'
+ with_items:
+ - regexp: '^dist_dir=.*'
+ line: 'dist_dir=/home/ubuntu/moon/moonv4/moon_orchestrator/dist'
+ - regexp: '^password=.*'
+ line: 'password={{ ADMIN_PASS }}'
+
+- name: configure moon.conf for moon slave
+ lineinfile:
+ dest: /etc/moon/moon.conf
+ regexp: '{{ item.regexp }}'
+ line: '{{ item.line }}'
+ with_items:
+ - regexp: '^slave_name=.*'
+ line: 'slave_name={{ moon_slave_name }}'
+ - regexp: '^master_url=.*'
+ line: 'master_url=rabbit://moon:p4sswOrd1@{{ moon_master_ip }}/moon'
+ - regexp: '^master_login.*'
+ line: 'master_login=moon'
+ - regexp: '^master_password=.*'
+ line: 'master_password=p4sswOrd1'
+ when: moon_slave == "Enable"
+
+- name: list container netwroks
+ shell: docker network ls --format \{\{.Name\}\}
+ register: result
+
+- name: dump template generated file content
+ debug:
+ msg: "{{ result.stdout }}"
+
+- name: create moon network
+ shell: docker network create -d bridge --subnet=172.18.0.0/16 --gateway=172.18.0.1 moon
+ when: result.stdout.find("moon") == -1
+
+- name: list containers
+ shell: docker ps --format \{\{.Names\}\}
+ register: result
+
+- name: start rabbitmq
+ shell: |
+ docker run -dti \
+ --net=moon \
+ --hostname messenger \
+ --name messenger \
+ --link messenger:messenger \
+ -e RABBITMQ_DEFAULT_USER=moon \
+ -e RABBITMQ_DEFAULT_PASS=p4sswOrd1 \
+ -e RABBITMQ_NODENAME=rabbit@messenger \
+ -e RABBITMQ_DEFAULT_VHOST=moon \
+ -p 5671:5671 \
+ -p 5672:5672 \
+ rabbitmq:3-management
+ when: result.stdout.find("messenger") == -1
+
+- name: dump template generated file content
+ debug:
+ msg: "{{ result.stdout }}"
+
+- name: start mysql
+ shell: docker run -dti \
+ --net=moon \
+ --hostname db \
+ --name db \
+ -e MYSQL_ROOT_PASSWORD=p4sswOrd1 \
+ -e MYSQL_DATABASE=moon \
+ -e MYSQL_USER=moon \
+ -e MYSQL_PASSWORD=p4sswOrd1 \
+ -p 3306:3306 \
+ mysql:latest
+ when: result.stdout.find("db") == -1
+
+- name: set messenger and db hosts name
+ remote_user: root
+ lineinfile:
+ dest: /etc/hosts
+ regexp: 'messenger'
+ line: '127.0.0.1 messenger db'
+
+- name: set keystone hosts name
+ remote_user: root
+ lineinfile:
+ dest: /etc/hosts
+ regexp: 'keystone'
+ line: '{{ internal_vip.ip }} keystone'
+
+- name: update pip
+ remote_user: root
+ shell: pip3 install pip --upgrade
+
+- name: run moon build_all.sh
+ shell: |
+ export MOON_HOME=/home/ubuntu/moon/moonv4;
+ cd ${MOON_HOME}/bin;
+ source build_all.sh;
+ args:
+ executable: /bin/bash
+
+- name: modify moon start.sh
+ lineinfile:
+ dest: /home/ubuntu/moon/moonv4/bin/start.sh
+ state: absent
+ regexp: "{{ item }}"
+ with_items:
+ - "^sleep 20s"
+ - "^.*starting Keystone container.*"
+ - "^docker run .*keystone.*"
+
+- name: run moon start.sh
+ shell: |
+ export MOON_HOME=/home/ubuntu/moon/moonv4;
+ cd ${MOON_HOME}/moon_orchestrator;
+ if [ ! -d tests/venv ]; then
+ pyvenv tests/venv;
+ source tests/venv/bin/activate;
+ pip3 install -r requirements.txt --upgrade;
+ pip3 install dist/moon_db-0.1.0.tar.gz --upgrade;
+ pip3 install dist/moon_utilities-0.1.0.tar.gz --upgrade;
+ pip3 install . --upgrade;
+ cd ../moon_db/;
+ pip3 install -r requirements.txt --upgrade;
+ else
+ source tests/venv/bin/activate;
+ fi
+ killall -9 /home/ubuntu/moon/moonv4/moon_orchestrator/tests/venv/bin/python3.5
+ sleep 3
+ ( ( nohup ../bin/start.sh > /tmp/start.log 2>&1 ) & );
+ args:
+ executable: /bin/bash
+
+- name: fetch template generated file content
+ shell: whoami
+ register: template_gen_out
+
+- name: dump template generated file content
+ debug:
+ msg: "{{ template_gen_out.stdout }}"
diff --git a/plugins/moon/roles/moon/templates/compute.j2 b/plugins/moon/roles/moon/templates/compute.j2
new file mode 100755
index 00000000..7adfa12c
--- /dev/null
+++ b/plugins/moon/roles/moon/templates/compute.j2
@@ -0,0 +1,52 @@
+# This file describes the network interfaces available on your system
+# and how to activate them. For more information, see interfaces(5).
+
+# The loopback network interface
+auto lo
+iface lo inet loopback
+
+
+# Physical interface
+auto eth0
+iface eth0 inet manual
+
+
+# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface
+auto {{sys_intf_mappings["mgmt"]["interface"]}}.{{sys_intf_mappings["mgmt"]["vlan_tag"]}}
+iface {{sys_intf_mappings["mgmt"]["interface"]}}.{{sys_intf_mappings["mgmt"]["vlan_tag"]}} inet manual
+ vlan-raw-device {{sys_intf_mappings["mgmt"]["interface"]}}
+
+# Storage network VLAN interface (optional)
+auto {{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}}
+iface {{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}} inet manual
+ vlan-raw-device {{sys_intf_mappings["storage"]["interface"]}}
+
+# OpenStack Networking VLAN bridge
+auto br-vlan
+iface br-vlan inet static
+ bridge_stp off
+ bridge_waitport 0
+ bridge_fd 0
+ bridge_ports {{ network_cfg["provider_net_mappings"][0]["interface"] }}
+ address {{ip_settings[inventory_hostname]["br-prv"]["ip"]}}
+ netmask 255.255.255.0
+ gateway {{ip_settings[inventory_hostname]["br-prv"]["gw"]}}
+ offload-sg off
+ # Create veth pair, don't bomb if already exists
+ pre-up ip link add br-vlan-veth type veth peer name eth12 || true
+ # Set both ends UP
+ pre-up ip link set br-vlan-veth up
+ pre-up ip link set eth12 up
+ # Delete veth pair on DOWN
+ post-down ip link del br-vlan-veth || true
+ bridge_ports br-vlan-veth
+
+# compute storage bridge
+auto br-storage
+iface br-storage inet static
+ bridge_stp off
+ bridge_waitport 0
+ bridge_fd 0
+ bridge_ports {{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}}
+ address {{ip_settings[inventory_hostname]["storage"]["ip"]}}
+ netmask 255.255.252.0
diff --git a/plugins/moon/roles/moon/templates/ifcfg-br-mgmt b/plugins/moon/roles/moon/templates/ifcfg-br-mgmt
new file mode 100755
index 00000000..7f1931c8
--- /dev/null
+++ b/plugins/moon/roles/moon/templates/ifcfg-br-mgmt
@@ -0,0 +1,7 @@
+DEVICE=br-mgmt
+TYPE=Bridge
+IPADDR={{host_info[inventory_hostname].MGMT_IP}}
+PREFIX=24
+BOOTPROTO=none
+ONBOOT=yes
+DELAY=0
diff --git a/plugins/moon/roles/moon/templates/ifcfg-br-storage b/plugins/moon/roles/moon/templates/ifcfg-br-storage
new file mode 100755
index 00000000..3c1db126
--- /dev/null
+++ b/plugins/moon/roles/moon/templates/ifcfg-br-storage
@@ -0,0 +1,8 @@
+DEVICE=br-storage
+TYPE=Bridge
+IPADDR={{ ip_settings[inventory_hostname]["storage"]["ip"] }}
+NETMASK=255.255.255.0
+BOOTPROTO=none
+DEFROUTE="no"
+ONBOOT=yes
+DELAY=0
diff --git a/plugins/moon/roles/moon/templates/ifcfg-br-vlan b/plugins/moon/roles/moon/templates/ifcfg-br-vlan
new file mode 100755
index 00000000..4349a3f1
--- /dev/null
+++ b/plugins/moon/roles/moon/templates/ifcfg-br-vlan
@@ -0,0 +1,11 @@
+DEVICE=br-vlan
+TYPE=Bridge
+IPADDR={{ ip_settings[inventory_hostname]["br-prv"]["ip"] }}
+PREFIX=24
+GATEWAY={{ ip_settings[inventory_hostname]["br-prv"]["gw"] }}
+BOOTPROTO=none
+ONBOOT=yes
+DELAY=0
+DEFROUTE="yes"
+DNS1=8.8.8.8
+DNS2=8.8.4.4
diff --git a/plugins/moon/roles/moon/templates/ifcfg-br-vxlan b/plugins/moon/roles/moon/templates/ifcfg-br-vxlan
new file mode 100755
index 00000000..d2a0cb86
--- /dev/null
+++ b/plugins/moon/roles/moon/templates/ifcfg-br-vxlan
@@ -0,0 +1,8 @@
+DEVICE=br-vxlan
+TYPE=Bridge
+IPADDR={{host_info[inventory_hostname].VXLAN_IP}}
+NETMASK=255.255.252.0
+BOOTPROTO=none
+DEFROUTE="no"
+ONBOOT=yes
+DELAY=0
diff --git a/plugins/moon/roles/moon/templates/ifcfg-if.storage b/plugins/moon/roles/moon/templates/ifcfg-if.storage
new file mode 100755
index 00000000..96afb1bd
--- /dev/null
+++ b/plugins/moon/roles/moon/templates/ifcfg-if.storage
@@ -0,0 +1,4 @@
+DEVICE={{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}}
+BOOTPROTO=none
+ONBOOT=yes
+VLAN=yes
diff --git a/plugins/moon/roles/moon/templates/ifcfg-if.vxlan b/plugins/moon/roles/moon/templates/ifcfg-if.vxlan
new file mode 100755
index 00000000..9fb19b0c
--- /dev/null
+++ b/plugins/moon/roles/moon/templates/ifcfg-if.vxlan
@@ -0,0 +1,4 @@
+DEVICE={{sys_intf_mappings["mgmt"]["interface"]}}.{{sys_intf_mappings["mgmt"]["vlan_tag"]}}
+BOOTPROTO=none
+ONBOOT=yes
+VLAN=yes
diff --git a/plugins/moon/roles/moon/templates/sources.list.lab b/plugins/moon/roles/moon/templates/sources.list.lab
new file mode 100755
index 00000000..b1e00d05
--- /dev/null
+++ b/plugins/moon/roles/moon/templates/sources.list.lab
@@ -0,0 +1,7 @@
+deb [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial main restricted universe multiverse
+deb [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-security main restricted universe multiverse
+deb [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-updates main restricted universe multiverse
+
+deb-src [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial main restricted universe multiverse
+deb-src [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-security main restricted universe multiverse
+deb-src [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-updates main restricted universe multiverse
diff --git a/plugins/moon/roles/moon/templates/sources.list.official b/plugins/moon/roles/moon/templates/sources.list.official
new file mode 100755
index 00000000..799e4b58
--- /dev/null
+++ b/plugins/moon/roles/moon/templates/sources.list.official
@@ -0,0 +1,36 @@
+# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
+# newer versions of the distribution.
+
+deb http://archive.ubuntu.com/ubuntu/ xenial main restricted
+deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted
+
+## Major bug fix updates produced after the final release of the
+## distribution.
+deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted
+deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted
+
+## Uncomment the following two lines to add software from the 'universe'
+## repository.
+## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
+## team. Also, please note that software in universe WILL NOT receive any
+## review or updates from the Ubuntu security team.
+deb http://archive.ubuntu.com/ubuntu/ xenial universe
+deb-src http://archive.ubuntu.com/ubuntu/ xenial universe
+deb http://archive.ubuntu.com/ubuntu/ xenial-updates universe
+deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates universe
+
+## N.B. software from this repository may not have been tested as
+## extensively as that contained in the main release, although it includes
+## newer versions of some applications which may provide useful features.
+## Also, please note that software in backports WILL NOT receive any review
+## or updates from the Ubuntu security team.
+# deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted
+# deb-src http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted
+
+deb http://archive.ubuntu.com/ubuntu/ xenial-security main restricted
+deb-src http://archive.ubuntu.com/ubuntu/ xenial-security main restricted
+deb http://archive.ubuntu.com/ubuntu/ xenial-security universe
+deb-src http://archive.ubuntu.com/ubuntu/ xenial-security universe
+# deb http://archive.ubuntu.com/ubuntu/ xenial-security multiverse
+# deb-src http://archive.ubuntu.com/ubuntu/ xenial-security multiverse
+
diff --git a/plugins/moon/roles/moon/vars/main.yml b/plugins/moon/roles/moon/vars/main.yml
new file mode 100755
index 00000000..783ea0d0
--- /dev/null
+++ b/plugins/moon/roles/moon/vars/main.yml
@@ -0,0 +1,10 @@
+# #############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+# #############################################################################
+---
+LOCAL_REPOSITORY_IP: "192.168.137.222"