############################################################################## # 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: edit ml2_conf.ini shell: | crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security; - name: Restart neutron-server service: name=neutron-server state=restarted - name: "create haproxy configuration for tacker" template: src: "haproxy-tacker-cfg.j2" dest: "/tmp/haproxy-tacker.cfg" - name: get the current haproxy configuration shell: cat /etc/haproxy/haproxy.cfg register: ha_cfg - name: "combination of the haproxy configuration" shell: "cat /tmp/haproxy-tacker.cfg >> /etc/haproxy/haproxy.cfg" when: ha_cfg.stdout.find('9890') == -1 - name: "delete temporary configuration file" file: dest: "/tmp/haproxy-tacker.cfg" state: "absent" - name: "restart haproxy" service: name: "haproxy" state: "restarted" - name: drop and recreate tacker database shell: | mysql -e "drop database if exists tacker;"; mysql -e "create database tacker character set utf8;"; mysql -e "grant all on tacker.* to 'tacker'@'%' identified by 'TACKER_DBPASS';"; when: inventory_hostname == haproxy_hosts.keys()[0] - name: get the openstack user info shell: . /opt/admin-openrc.sh; openstack user list register: user_info - name: get the openstack service info shell: . /opt/admin-openrc.sh; openstack service list register: service_info - name: get the openstack endpoint info shell: . /opt/admin-openrc.sh; openstack endpoint list register: endpoint_info - name: delete the existed tacker endpoint shell: | . /opt/admin-openrc.sh; openstack endpoint delete \ $(openstack endpoint list | grep tacker | awk '{print $2}') when: endpoint_info.stdout.find('tacker') != -1 and inventory_hostname == haproxy_hosts.keys()[0] - name: delete the existed tacker service shell: | . /opt/admin-openrc.sh; openstack service delete tacker; when: service_info.stdout.find('tacker') != -1 and inventory_hostname == haproxy_hosts.keys()[0] - name: delete the existed tacker user shell: | . /opt/admin-openrc.sh; openstack user delete tacker; when: user_info.stdout.find('tacker') != -1 and inventory_hostname == haproxy_hosts.keys()[0] - name: create tacker user with admin privileges shell: | . /opt/admin-openrc.sh; openstack user create --password console tacker; openstack role add --project service --user tacker admin; when: inventory_hostname == haproxy_hosts.keys()[0] - name: creat tacker service shell: | . /opt/admin-openrc.sh; openstack service create --name tacker \ --description "Tacker Project" nfv-orchestration when: inventory_hostname == haproxy_hosts.keys()[0] - name: provide an endpoint to tacker service shell: | . /opt/admin-openrc.sh; \ openstack endpoint create --region RegionOne \ nfv-orchestration public 'http://{{ public_vip.ip }}:9890/'; openstack endpoint create --region RegionOne \ nfv-orchestration admin 'http://{{ internal_vip.ip }}:9890/'; openstack endpoint create --region RegionOne \ nfv-orchestration internal 'http://{{ internal_vip.ip }}:9890/'; when: inventory_hostname == haproxy_hosts.keys()[0] - name: install tacker and tacker client shell: | pip install tacker python-tackerclient - name: create 'tacker' directory in '/var/cache' shell: | mkdir -p /var/cache/tacker - name: create 'tacker' directory in '/var/log' shell: mkdir -p /var/log/tacker - name: get the policy file of heat shell: cat /etc/heat/policy.json | grep Flavor register: heat_info - name: update the policy file of heat lineinfile: dest: /etc/heat/policy.json regexp: ' "resource_types:OS::Nova::Flavor' line: ' "resource_types:OS::Nova::Flavor": "role:admin",' when: heat_info.stdout.find('role') == -1 - name: restart heat services service: name={{ item }} state=restarted enabled=yes with_items: "{{ heat_services }}" - name: copy tacker configs template: src={{ item.src }} dest=/opt/os_templates with_items: "{{ tacker_configs_templates }}" - name: edit tacker configuration file shell: | crudini --merge /usr/local/etc/tacker/tacker.conf \ < /opt/os_templates/tacker.j2 - name: populate tacker database shell: | . /opt/admin-openrc.sh; \ /usr/local/bin/tacker-db-manage \ --config-file /usr/local/etc/tacker/tacker.conf upgrade head when: inventory_hostname == haproxy_hosts.keys()[0] - name: create tacker service copy: src=tacker.service dest=/lib/systemd/system/ - name: create tacker service work dir file: path=/var/lib/tacker state=directory - name: link the tacker service file: src: /lib/systemd/system/tacker.service dest: /etc/systemd/system/multi-user.target.wants/tacker.service state: link - name: start tacker service shell: service tacker start - name: create tackerc file template: src=tackerc.sh dest=/opt/tackerc.sh mode=777 - name: create nfvrc file template: src=nfvrc.sh dest=/opt/nfvrc.sh mode=777 - name: get the nfv_user info shell: . /opt/tackerc.sh; openstack user list register: nfvuser_info - name: delete the existed nfv user shell: . /opt/tackerc.sh; openstack user delete nfv_user when: nfvuser_info.stdout.find('nfv') != -1 and inventory_hostname == haproxy_hosts.keys()[0] - name: get the openstack project info shell: . /opt/tackerc.sh; openstack project list register: nfvproject_info - name: delete the existed nfv project shell: | . /opt/tackerc.sh; openstack project delete $(openstack project list | grep nfv | awk '{print $2}') when: nfvproject_info.stdout.find('nfv') != -1 and inventory_hostname == haproxy_hosts.keys()[0] - name: create an nfv project shell: . /opt/tackerc.sh; openstack project create --description "NFV Project" nfv when: inventory_hostname == haproxy_hosts.keys()[0] - name: create nfv user with admin privileges shell: | . /opt/tackerc.sh; openstack user create --password console nfv_user; openstack role add --project nfv --user nfv_user admin; when: inventory_hostname == haproxy_hosts.keys()[0] - name: create config.yml template: src=config.yaml dest=/opt/config.yaml - name: check if tacker running shell: . /opt/tackerc.sh; while (!(tacker ext-list)); do sleep 30; done - name: register VIM to tacker shell: | . /opt/tackerc.sh; tacker vim-register --config-file /opt/config.yaml --description "Default VIM" VIM0 when: inventory_hostname == haproxy_hosts.keys()[0] - name: restart tacker service shell: service tacker stop; service tacker start