Bug fix for tacker installation 25/19825/2
authorYifei Xue <xueyifei@huawei.com>
Tue, 30 Aug 2016 11:30:11 +0000 (19:30 +0800)
committerYifei Xue <xueyifei@huawei.com>
Tue, 30 Aug 2016 15:22:09 +0000 (23:22 +0800)
JIRA: COMPASS-430

Change-Id: I622b092dac3d77d4094cc470b8eeb9b0628d83e9
Signed-off-by: Yifei Xue <xueyifei@huawei.com>
deploy/adapters/ansible/roles/tacker/tasks/tacker_controller.yml

index 564b550..4e92557 100755 (executable)
     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('8888') == -1
 
 - name: "delete temporary configuration file"
   file:
          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]