diff options
author | chenshuai@huawei.com <chenshuai@huawei.com> | 2016-01-18 10:05:58 +0800 |
---|---|---|
committer | chenshuai@huawei.com <chenshuai@huawei.com> | 2016-01-18 10:14:45 +0800 |
commit | 77944ac2791a631cfa785d16cc32dae8082b2719 (patch) | |
tree | 76e6a13fdc27a61fb801f211169dfe33b9713e19 /deploy/adapters/ansible/roles/open-contrail/tasks/provision | |
parent | dd509497f4c6865b26cd2e7aa2ea0ecc501edb96 (diff) |
bugfix: opencontrail automation deployment scripts
JIRA: COMPASS-277
Change-Id: Ia1f52c6e8e3de520cf06de99550c17879aaed2d7
Signed-off-by: chenshuai@huawei.com <chenshuai@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible/roles/open-contrail/tasks/provision')
7 files changed, 110 insertions, 49 deletions
diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/.provision-compute.yml.swp b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/.provision-compute.yml.swp Binary files differdeleted file mode 100644 index 41980448..00000000 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/.provision-compute.yml.swp +++ /dev/null diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml index a9f34ed6..f1706700 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml @@ -4,23 +4,45 @@ # tasks: - name: "recover rabbitmq-server service script" - shell: if [ ! -f "\/etc\/init.d\/rabbitmq-server.initd.supervisord" ] ; then mv /etc/init.d/rabbitmq-server.initd.supervisord /home/rabbitmq-server.initd.supervisord; mv /etc/init.d/rabbitmq-server /home/rabbit-server; mv /etc/init.d/rabbitmq-server.backup /etc/init.d/rabbitmq-server; fi + shell: cp /home/rabbitmq-server /etc/init.d/rabbitmq-server - name: "restart rabbitmq-server" service: name: "rabbitmq-server" - state: "restarted" + state: "restarted" + +- name: "wait rabbitmq-server start" + shell: sleep 5 + +- name: "restart contrail-discovery" + service: + name: "contrail-discovery" + state: "restarted" + +- name: "wait contrail-discovery" + shell: sleep 5 + +- name: "restart contrail-api" + service: + name: "contrail-api" + state: "restarted" + +- name: "check contrail-api" + shell: lsof -ni :8082 ; while [ $? -ne 0 ]; do sleep 10; lsof -ni :8082; done; sleep 20; + +- name: "wait contrail-api" + shell: sleep 20 - name: "provision config node" shell: "python /opt/contrail/utils/provision_config_node.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --host_name {{ ansible_hostname }} --host_ip {{ contrail_address }}" - when: inventory_hostname in groups['opencontrail_config'] +# when: inventory_hostname in groups['opencontrail_config'] #- hosts: database # sudo: yes # tasks: - name: "provision database node" shell: "python /opt/contrail/utils/provision_database_node.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --host_name {{ ansible_hostname }} --host_ip {{ contrail_address }}" - when: inventory_hostname in groups['opencontrail_database'] +# when: inventory_hostname in groups['opencontrail_database'] #- hosts: collector @@ -28,14 +50,14 @@ # tasks: - name: "provision collector node" shell: "python /opt/contrail/utils/provision_analytics_node.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --host_name {{ ansible_hostname }} --host_ip {{ contrail_address }}" - when: inventory_hostname in groups['opencontrail_collector'] +# when: inventory_hostname in groups['opencontrail_collector'] #- hosts: control # sudo: yes # tasks: - name: "provision control node" shell: "python /opt/contrail/utils/provision_control.py --api_server_ip {{ contrail_haproxy_address }} --api_server_port 8082 --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --host_name {{ ansible_hostname }} --host_ip {{ contrail_address }} --router_asn {{ contrail_router_asn }}" - when: inventory_hostname in groups['opencontrail_control'] +# when: inventory_hostname in groups['opencontrail_control'] #- hosts: config # sudo: yes @@ -43,7 +65,7 @@ - name: "provision metadata services" shell: "python /opt/contrail/utils/provision_linklocal.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --ipfabric_service_ip 10.84.50.1 --ipfabric_service_port 8775 --linklocal_service_name metadata --linklocal_service_ip 169.254.169.254 --linklocal_service_port 80" run_once: yes - when: inventory_hostname in groups['opencontrail_config'] +# when: inventory_hostname in groups['opencontrail_config'] #- hosts: config @@ -52,5 +74,5 @@ - name: "provision encap" shell: "python /opt/contrail/utils/provision_encap.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --oper add --encap_priority MPLSoUDP,MPLSoGRE,VXLAN" run_once: yes - when: inventory_hostname in groups['opencontrail_config'] +# when: inventory_hostname in groups['opencontrail_config'] diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-compute.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-compute.yml index c8db15b6..30d836d9 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-compute.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-compute.yml @@ -77,6 +77,10 @@ - "sed -i -n -e '/auto .*/,$p' /tmp/contrail-interfaces-bottom" - "cat /tmp/contrail-interfaces-top /tmp/contrail-interfaces-bottom > /etc/network/interfaces" +- name: get last ip address + shell: expr substr `cat /etc/hostname` 5 1 + register: lastip + - name: "configure interface" lineinfile: dest: "/etc/network/interfaces" @@ -91,14 +95,25 @@ - "iface vhost0 inet static" - "\tpre-up /opt/contrail/bin/if-vhost0" - "\tnetwork_name application" - - "\taddress {{ contrail_vhost_address }}" + - "\taddress {{ contrail_vhost_address }}{{ lastip.stdout_lines[0] }}" - "\tnetmask {{ contrail_vhost_netmask }}" +################################################################################## + +- name: "copy vrouter script to compute" + template: + src: "../../templates/vrouter-functions.sh" + dest: "/opt/contrail/bin/vrouter-functions.sh" + - name: "load vrouter driver" command: su -s /bin/sh -c "insmod /var/lib/dkms/vrouter/2.21/build/vrouter.ko" + ignore_errors: true - name: "run vhost0 script" command: su -s /bin/sh -c "/opt/contrail/bin/if-vhost0" + ignore_errors: true + +################################################################################## - name: "delete temporary files" file: @@ -108,6 +123,8 @@ - "/tmp/contrail-interfaces-top" - "/tmp/contrail-interfaces-bottom" +################################################################################## + - name: "fix up contrail vrouter nodemgr config" ini_file: dest: "/etc/contrail/contrail-vrouter-nodemgr.conf" @@ -115,6 +132,27 @@ option: "server" value: "{{ contrail_haproxy_address }}" + +################################################################################## +########################### restart vrouter services ########################### + +- name: "restart supervisor service" + service: + name: "supervisor" + state: "restarted" + +- name: "restart vrouter nodemgr" + shell: ps aux | grep contrail-nodemgr | grep -v grep | awk '{print $2}' | xargs kill -9; + +- name: "restart vrouter agent" + service: + name: "contrail-vrouter-agent" + state: "restarted" + + +################################################################################## + + - name: "restart libvirt bin" service: name: "libvirt-bin" @@ -167,14 +205,14 @@ -################################################# -########### nova plugin workaround ############ -################################################# +####################################################################### +###################### nova plugin workaround ####################### +####################################################################### - name: "copy nova plugs on compute" - template: - src: "nova_contrail_vif.tar.gz" - dest: "/opt/nova_contrail_vif.tar.gz" + copy: + src: "../../templates/nova_contrail_vif.tar.gz" + dest: "/opt/nova_contrail_vif.tar.gz" - name: "unzip nova plugs" command: su -s /bin/sh -c "tar xzf /opt/nova_contrail_vif.tar.gz -C /opt/" @@ -182,15 +220,11 @@ - name: "remove original nova plugs" shell: rm -rf /usr/lib/python2.7/dist-packages/nova_contrail_vif/ -- name: "use new neutron plugs" +- name: "use new nova plugs" shell: mv /opt/nova_contrail_vif/ /usr/lib/python2.7/dist-packages/nova_contrail_vif/ ################################################# - - - - - name: "restart nova compute" service: name: "nova-compute" diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-config.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-config.yml index 99a18dba..ecbf3a44 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-config.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-config.yml @@ -30,27 +30,32 @@ # - { regexp: "^\\s*tune.bufsize", line: "\ttune.bufsize 16384" } # - { regexp: "^\\s*tune.maxrewrite", line: "\ttune.maxrewrite 1024" } -- name: "delete haproxy configuration for contrail" - shell: "sed -i -e '/^#contrail-marker-start/,/^#contrail-marker-end/d' /etc/haproxy/haproxy.cfg" +#chenshuai, add later +#- name: "delete haproxy configuration for contrail" +# shell: "sed -i -e '/^#contrail-marker-start/,/^#contrail-marker-end/d' /etc/haproxy/haproxy.cfg" -- name: "create haproxy configuration for contrail" - template: +#chenshuai, add later +#- name: "create haproxy configuration for contrail" +# template: # src: "provision/haproxy-contrail-cfg.j2" - src: "../../templates/provision/haproxy-contrail-cfg.j2" - dest: "/tmp/haproxy-contrail.cfg" +# src: "../../templates/provision/haproxy-contrail-cfg.j2" +# dest: "/tmp/haproxy-contrail.cfg" -- name: "combination of the haproxy configuration" - shell: "cat /tmp/haproxy-contrail.cfg >> /etc/haproxy/haproxy.cfg" +#chenshuai, add later +#- name: "combination of the haproxy configuration" +# shell: "cat /tmp/haproxy-contrail.cfg >> /etc/haproxy/haproxy.cfg" -- name: "delete temporary configuration file" - file: - dest: "/tmp/haproxy-contrail.cfg" - state: "absent" +#chenshuai, add later +#- name: "delete temporary configuration file" +# file: +# dest: "/tmp/haproxy-contrail.cfg" +# state: "absent" -- name: "restart haproxy" - service: - name: "haproxy" - state: "restarted" +#chenshuai, add later +#- name: "restart haproxy" +# service: +# name: "haproxy" +# state: "restarted" # Compass is using this #- name: "create keepalived configuration" @@ -235,9 +240,9 @@ ########################################################### - name: "copy neutron plugs on controller" - template: - src: "neutron_plugin_contrail.tar.gz" - dest: "/opt/neutron_plugin_contrail.tar.gz" + copy: + src: "../../templates/neutron_plugin_contrail.tar.gz" + dest: "/opt/neutron_plugin_contrail.tar.gz" - name: "unzip neutron plugs" command: su -s /bin/sh -c "tar xzf /opt/neutron_plugin_contrail.tar.gz -C /opt/" diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-control.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-control.yml index 3da783e1..67b72c7e 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-control.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-control.yml @@ -17,14 +17,14 @@ dest: "/etc/ifmap-server/basicauthusers.properties" # line: "{{ hostvars[item]['contrail_address' ] }}:{{ hostvars[item]['contrail_address' ] }}" line: "{{ haproxy_hosts[item] }}:{{ haproxy_hosts[item] }}" - with_items: groups['opencontrail_control'] + with_items: groups['controller'] - name: "modify ifmap server basicauthusers properties for dns" lineinfile: dest: "/etc/ifmap-server/basicauthusers.properties" # line: "{{ hostvars[item]['contrail_address' ] }}.dns:{{ hostvars[item]['contrail_address' ] }}.dns" line: "{{ haproxy_hosts[item] }}.dns:{{ haproxy_hosts[item] }}.dns" - with_items: groups['opencontrail_control'] + with_items: groups['controller'] - name: "node-common" include: -node-common.yml diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-database.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-database.yml index b20491b5..7ccb5af1 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-database.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-database.yml @@ -54,7 +54,7 @@ set_fact: # dbseeds: "{{ hostvars[item.1][ contrail_address ] }}" dbseeds: "{{ haproxy_hosts[item.1] }}" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 == 0 @@ -66,7 +66,7 @@ set_fact: # dbseeds: "{{ dbseeds }},{{ hostvars[item.1]['contrail_address'] }}" dbseeds: "{{ dbseeds }},{{ haproxy_hosts[item.1] }}" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 == 1 @@ -122,7 +122,7 @@ regexp: "server.{{ item.0 + 1 }}=" # line: "server.{{ item.0 + 1 }}={{ hostvars[item.1]['contrail_address'] }}:2888:3888" line: "server.{{ item.0 + 1 }}={{ haproxy_hosts[item.1] }}:2888:3888" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] - name: "set zookeeper unique id" @@ -130,7 +130,7 @@ template: src: "../../templates/provision/zookeeper-unique-id.j2" dest: "/var/lib/zookeeper/myid" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.1 == inventory_hostname @@ -146,7 +146,7 @@ set_fact: # zkaddrs: "{{ hostvars[item.1]['contrail_address'] }}:2181" zkaddrs: "{{ haproxy_hosts[item.1] }}:2181" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 == 0 @@ -155,7 +155,7 @@ set_fact: # zkaddrs: "{{ zkaddrs }},{{ hostvars[item.1]['contrail_address'] }}:2181" zkaddrs: "{{ zkaddrs }},{{ haproxy_hosts[item.1] }}:2181" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 > 0 diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-webui.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-webui.yml index 6758b8e7..e50f6a63 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-webui.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-webui.yml @@ -18,14 +18,14 @@ set_fact: # cassandra_addrs: "'{{ hostvars[item.1]['contrail_address'] }}'" cassandra_addrs: "'{{ haproxy_hosts[item.1] }}'" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 == 0 - name: "set second or more cassandra host addresses" set_fact: # cassandra_addrs: "{{ cassandra_addrs }}, '{{ hostvars[item.1]['contrail_address'] }}'" cassandra_addrs: "{{ cassandra_addrs }}, '{{ haproxy_hosts[item.1] }}'" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 > 0 - name: "modify webui global js" |