Gabe Black | 4c040b7 | 2016-11-17 22:35:04 +0000 | [diff] [blame] | 1 | --- |
| 2 | |
| 3 | - name: check if work should be done |
| 4 | stat: path=/tmp/init_completed |
| 5 | register: result |
| 6 | |
| 7 | - name: get interface of private_ip |
| 8 | register: private_interface |
| 9 | shell: | |
| 10 | ip addr | awk '/^[0-9]+:/ { sub(/:/,"",$2); iface=$2 } /^[[:space:]]*inet / { split($2, a, "/"); print iface" : "a[1] }' | grep "{{ private_ip }}" | cut -d " " -f 1 |
| 11 | when: result.stat.exists == False |
| 12 | |
| 13 | - name: run vnf-setup |
| 14 | shell: vnf-setup --controller-address {{controller_ip}} --controller-port 30500 --test-interface {{ private_interface.stdout }} --enable-single-test-mode |
| 15 | when: result.stat.exists == False |
| 16 | |
| 17 | - name: rm dhcp cache |
| 18 | shell: rm /var/lib/dhcp/dhclient.leases |
| 19 | when: result.stat.exists == False |
| 20 | |
| 21 | - name: rm test interface from /etc/network/interfaces |
| 22 | shell: | |
| 23 | sed -i '/{{ private_interface.stdout }}/d' /etc/network/interfaces |
| 24 | when: result.stat.exists == False |
| 25 | |
| 26 | - name: reset test interface ip |
| 27 | shell: ifconfig {{ private_interface.stdout }} 0.0.0.0 |
| 28 | when: result.stat.exists == False |
| 29 | |
| 30 | - name: restart qt services |
| 31 | shell: /etc/init.d/vqt_startup restart |
| 32 | when: result.stat.exists == False |
| 33 | |
| 34 | - name: record task completed |
| 35 | shell: echo "done" > /tmp/init_completed |
| 36 | |
| 37 | - name: run reflector |
| 38 | command: python /root/fusion_controller.py --start-reflector --controller-ip "{{ controller_ip }}" --reflector-ip "{{ public_ip }}" --reflector-src-ip "{{ private_ip }}" |
| 39 | when: is_reflector |
| 40 | |
| 41 | - name: run initiator |
| 42 | command: python /root/fusion_controller.py --start-initiator --controller-ip "{{ controller_ip }}" --initiator-ip "{{ public_ip }}" --initiator-src-ip "{{ private_ip }}" --reflector-ip "{{ reflector_public_ip }}" --reflector-src-ip "{{ reflector_ip }}" |
| 43 | when: is_initiator |
| 44 | |
| 45 | - name: stop reflector |
| 46 | command: python /root/fusion_controller.py --stop-reflector --controller-ip "{{ controller_ip }}" |
| 47 | when: is_reflector == False |
| 48 | |
| 49 | - name: stop initiator |
| 50 | command: python /root/fusion_controller.py --stop-initiator --controller-ip "{{ controller_ip }}" |
| 51 | when: is_initiator == False |