aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/moon/tasks
diff options
context:
space:
mode:
authorQiLiang <liangqi1@huawei.com>2017-05-08 11:09:02 +0800
committerqi liang <liangqi1@huawei.com>2017-05-15 08:24:35 +0000
commitf20effca792bb5dfa2898585f3431de5d296064f (patch)
tree2323e6d85a03d8673e1a5fc89d7658f1575cb2e5 /deploy/adapters/ansible/roles/moon/tasks
parentf0f025b1137da4ab12b0db76620c332fac3335bc (diff)
Update moon role for moonv4
JIRA: - To deploy moon(master/slave) scenario configure moon role in DHA file like: - name: host4 roles: - moon To deploy moon master, export MOON_CFG env like below compass deploy: export MOON_CFG="master:flag=Disable,slave:flag=Enable,slave:name=slave1,slave:master_ip=master_ip" To deploy moon slave, export MOON_CFG env like below compass deploy: export MOON_CFG="master:flag=Enable,slave:flag=Disable,slave:name=slave1,slave:master_ip=master_ip" Change-Id: Ie300a85979af31634ab0660ccee1ee8b094110b5 Signed-off-by: QiLiang <liangqi1@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible/roles/moon/tasks')
-rw-r--r--deploy/adapters/ansible/roles/moon/tasks/main.yml4
-rw-r--r--deploy/adapters/ansible/roles/moon/tasks/moon-compute.yml16
-rw-r--r--deploy/adapters/ansible/roles/moon/tasks/moon-controller.yml235
-rwxr-xr-x[-rw-r--r--]deploy/adapters/ansible/roles/moon/tasks/moon.yml207
4 files changed, 203 insertions, 259 deletions
diff --git a/deploy/adapters/ansible/roles/moon/tasks/main.yml b/deploy/adapters/ansible/roles/moon/tasks/main.yml
index a3511de7..ffac2139 100644
--- a/deploy/adapters/ansible/roles/moon/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/moon/tasks/main.yml
@@ -1,5 +1,5 @@
#############################################################################
-# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+# 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
@@ -8,4 +8,4 @@
##############################################################################
---
- include: moon.yml
- when: moon == "Enable"
+ when: ansible_os_family == "Debian"
diff --git a/deploy/adapters/ansible/roles/moon/tasks/moon-compute.yml b/deploy/adapters/ansible/roles/moon/tasks/moon-compute.yml
deleted file mode 100644
index c2ca2fcf..00000000
--- a/deploy/adapters/ansible/roles/moon/tasks/moon-compute.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-#############################################################################
-# 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: update api-paste.ini
- template: src=api-paste.ini dest=/etc/nova/api-paste.ini backup=yes
-
-- name: restart nova task
- service: name={{ item }} state=restarted enabled=yes
- with_items:
- - nova-compute
diff --git a/deploy/adapters/ansible/roles/moon/tasks/moon-controller.yml b/deploy/adapters/ansible/roles/moon/tasks/moon-controller.yml
deleted file mode 100644
index ad030bda..00000000
--- a/deploy/adapters/ansible/roles/moon/tasks/moon-controller.yml
+++ /dev/null
@@ -1,235 +0,0 @@
-##############################################################################
-# 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
-##############################################################################
----
-# install all packages
-- name: install unzip packages
- shell: apt-get install -y python-pip unzip
-
-# download master.zip
-- name: get image http server
- shell: awk -F'=' '/compass_server/ {print $2}' /etc/compass.conf
- register: http_server
-
-- name: download keystone-moon packages
- get_url:
- url: "http://{{ http_server.stdout_lines[0] }}/packages/moon/master.zip"
- dest: /tmp/master.zip
- mode: 0444
-
-- name: extract keystone-moon packages
- unarchive: src=/tmp/master.zip dest=/tmp copy=no
-
-# install all dependencies
-- name: copy scripts
- copy: src=get_deb_depends.py dest=/tmp/get_deb_depends.py
-
-- name: install keystone-moon dependencies
- shell: |
- apt-get install \
- $(python /tmp/get_deb_depends.py /tmp/moon-bin-master/*.deb)
- when: ansible_os_family == "Debian"
-
-- name: delete configuration file
- shell: >
- rm -f {{ apache_config_dir }}/sites-enabled/wsgi-keystone.conf;
- rm -f {{ apache_config_dir }}/sites-available/wsgi-keystone.conf;
-
-# install keystone moon
-- name: copy scripts
- copy: src=deb.conf dest=/tmp/deb.conf
-
-- name: install keystone moon
- shell: >
- export DEBIAN_FRONTEND="noninteractive";
- sudo -E dpkg -i /tmp/moon-bin-master/*moon*.deb;
-
-# - name: install keystone moon
-# shell: >
-# export DEBIAN_FRONTEND="noninteractive";
-# sudo -E debconf-set-selections python-keystone < /tmp/deb.conf;
-# sudo -E dpkg -i /tmp/moon-bin-master/*moon*.deb;
-
-- name: stop keystone task
- shell: >
- service keystone stop;
- mv /etc/init.d/keystone /home/;
- mv /etc/init/keystone.conf /home/;
- mv /lib/systemd/system/keystone.service /home/;
-
-# config keystone and apache2
-- name: delete sqlite database
- file:
- path: /var/lib/keystone/keystone.db
- state: absent
-
-# - name: update keystone conf
-# template: src=keystone.conf dest=/etc/keystone/keystone.conf backup=yes
-
-
-# - name: assure listen port exist
-# lineinfile:
-# dest: '{{ apache_config_dir }}/ports.conf'
-# regexp: '{{ item.regexp }}'
-# line: '{{ item.line}}'
-# with_items:
-# - regexp: "^Listen {{ internal_ip }}:5000"
-# line: "Listen {{ internal_ip }}:5000"
-# - regexp: "^Listen {{ internal_ip }}:35357"
-# line: "Listen {{ internal_ip }}:35357"
-
-- name: update apache2 configs
- template:
- src: wsgi-keystone.conf.j2
- dest: '{{ apache_config_dir }}/sites-available/wsgi-keystone.conf'
- when: ansible_os_family == 'Debian'
-
-- name: enable keystone server
- file:
- src: "{{ apache_config_dir }}/sites-available/wsgi-keystone.conf"
- dest: "{{ apache_config_dir }}/sites-enabled/wsgi-keystone.conf"
- state: "link"
- when: ansible_os_family == 'Debian'
-
-# - name: keystone source files
-# template: src={{ item }} dest=/opt/{{ item }}
-# with_items:
-# - admin-openrc.sh
-# - demo-openrc.sh
-
-# keystone paste ini
-- name: backup keystone-paste.ini
- shell: >
- cp /etc/keystone/keystone-paste.ini /etc/keystone/keystone-paste.ini.bak;
-
-- name: config keystone-paste.ini
- shell: >
- sed -i "3i[pipeline:moon_pipeline]\n" /etc/keystone/keystone-paste.ini;
- sed -i "5i[app:moon_service]\nuse = egg:keystone#moon_service\n" \
- /etc/keystone/keystone-paste.ini;
- sed -i "s/use = egg:Paste#urlmap/use = egg:Paste#urlmap\n\/moon = moon_pipeline/" \
- /etc/keystone/keystone-paste.ini;
-
-- name: config keystone-paste.ini
- blockinfile:
- dest: /etc/keystone/keystone-paste.ini
- insertafter: "pipeline:moon_pipeline"
- block: >
- pipeline = sizelimit url_normalize request_id build_auth_context
- token_auth admin_token_auth json_body ec2_extension_v3 s3_extension moon_service
-
-# moon log
-- name: moon log
- shell: >
- sudo mkdir /var/log/moon/;
- sudo chown keystone /var/log/moon/;
- sudo addgroup moonlog;
- sudo chgrp moonlog /var/log/moon/;
- sudo touch /var/log/moon/keystonemiddleware.log;
- sudo touch /var/log/moon/system.log;
- sudo chgrp moonlog /var/log/moon/keystonemiddleware.log;
- sudo chgrp moonlog /var/log/moon/system.log;
- sudo chmod g+rw /var/log/moon;
- sudo chmod g+rw /var/log/moon/keystonemiddleware.log;
- sudo chmod g+rw /var/log/moon/system.log;
- sudo adduser keystone moonlog;
- # sudo adduser swift moonlog;
- sudo adduser nova moonlog;
-
-
-# keystone db sync
-- name: keystone db sync
- shell: >
- sudo /usr/bin/keystone-manage db_sync;
- sudo /usr/bin/keystone-manage db_sync --extension moon;
- when: inventory_hostname == haproxy_hosts.keys()[0]
-
-- name: wait for keystone ready
- wait_for: port=35357 delay=3 timeout=10 host={{ internal_ip }}
-
-# moon workaround
-- name: copy scripts
- copy:
- src: controllers.py
- dest: /usr/lib/python2.7/dist-packages/keystone/contrib/moon/controllers.py
-
-# apache2 restart
-- name: restart apache2
- service: name={{ item }} state=restarted enabled=yes
- with_items: services | union(services_noarch)
-
-# install moonclient
-- name: install moon client
- shell: sudo pip install /tmp/moon-bin-master/python-moonclient-0.1.tar.gz
-
-# - name: add tenants
-# keystone_user:
-# token: "{{ ADMIN_TOKEN }}"
-# endpoint: "http://{{ internal_ip }}:35357/v2.0"
-# tenant: "{{ item.tenant }}"
-# tenant_description: "{{ item.tenant_description }}"
-# with_items: "{{ os_users }}"
-# when: inventory_hostname == groups['controller'][0]
-
-# - name: add users
-# keystone_user:
-# token: "{{ ADMIN_TOKEN }}"
-# endpoint: "http://{{ internal_ip }}:35357/v2.0"
-# user: "{{ item.user }}"
-# tenant: "{{ item.tenant }}"
-# password: "{{ item.password }}"
-# email: "{{ item.email }}"
-# with_items: "{{ os_users }}"
-# when: inventory_hostname == groups['controller'][0]
-
-# - name: grant roles
-# keystone_user:
-# token: "{{ ADMIN_TOKEN }}"
-# endpoint: "http://{{ internal_ip }}:35357/v2.0"
-# user: "{{ item.user }}"
-# role: "{{ item.role }}"
-# tenant: "{{ item.tenant }}"
-# with_items: "{{ os_users }}"
-# when: inventory_hostname == groups['controller'][0]
-
-# - name: add endpoints
-# keystone_service:
-# token: "{{ ADMIN_TOKEN }}"
-# endpoint: "http://{{ internal_ip }}:35357/v2.0"
-# name: "{{ item.name }}"
-# type: "{{ item.type }}"
-# region: "{{ item.region}}"
-# description: "{{ item.description }}"
-# publicurl: "{{ item.publicurl }}"
-# internalurl: "{{ item.internalurl }}"
-# adminurl: "{{ item.adminurl }}"
-# with_items: "{{ os_services }}"
-# when: inventory_hostname == groups['controller'][0]
-
-- name: update api-paste.ini
- template: src=api-paste.ini dest=/etc/nova/api-paste.ini backup=yes
-
-# - name: update proxy-server conf
-# template: src=proxy-server.conf dest=/etc/swift/proxy-server.conf backup=yes
-
-# restart nova
-- name: restart nova
- service: name={{ item }} state=restarted enabled=yes
- with_items:
- - nova-api
- - nova-cert
- - nova-conductor
- - nova-consoleauth
- - nova-scheduler
-
-# restart swift
-# - name: restart swift
-# service: name={{ item }} state=restarted enabled=yes
-# with_items:
-# - swift-proxy
-# - memcached
diff --git a/deploy/adapters/ansible/roles/moon/tasks/moon.yml b/deploy/adapters/ansible/roles/moon/tasks/moon.yml
index 40e1c98c..54000145 100644..100755
--- a/deploy/adapters/ansible/roles/moon/tasks/moon.yml
+++ b/deploy/adapters/ansible/roles/moon/tasks/moon.yml
@@ -1,5 +1,5 @@
#############################################################################
-# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+# 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
@@ -7,10 +7,205 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
-- include_vars: "{{ ansible_os_family }}.yml"
+- name: setup sources.list
+ remote_user: root
+ copy:
+ src: sources.list
+ dest: /etc/apt/sources.list
+ mode: "u=rw,g=r,o=r"
-- include: moon-controller.yml
- when: inventory_hostname in groups['controller']
+- name: rm pip.conf
+ file:
+ path: /root/.pip/pip.conf
+ state: absent
-- include: moon-compute.yml
- when: inventory_hostname in groups['compute']
+- 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 }}"