| --- |
| |
| - name: check if work should be done |
| stat: path=/tmp/init_completed |
| register: result |
| |
| - name: get interface of private_ip |
| register: private_interface |
| shell: | |
| 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 |
| when: result.stat.exists == False |
| |
| - name: run vnf-setup |
| shell: vnf-setup --controller-address {{controller_ip}} --controller-port 30500 --test-interface {{ private_interface.stdout }} --enable-single-test-mode |
| when: result.stat.exists == False |
| |
| - name: rm dhcp cache |
| shell: rm /var/lib/dhcp/dhclient.leases |
| when: result.stat.exists == False |
| |
| - name: rm test interface from /etc/network/interfaces |
| shell: | |
| sed -i '/{{ private_interface.stdout }}/d' /etc/network/interfaces |
| when: result.stat.exists == False |
| |
| - name: reset test interface ip |
| shell: ifconfig {{ private_interface.stdout }} 0.0.0.0 |
| when: result.stat.exists == False |
| |
| - name: restart qt services |
| shell: /etc/init.d/vqt_startup restart |
| when: result.stat.exists == False |
| |
| - name: record task completed |
| shell: echo "done" > /tmp/init_completed |
| |
| - name: run reflector |
| command: python /root/fusion_controller.py --start-reflector --controller-ip "{{ controller_ip }}" --reflector-ip "{{ public_ip }}" --reflector-src-ip "{{ private_ip }}" |
| when: is_reflector |
| |
| - name: run initiator |
| 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 }}" |
| when: is_initiator |
| |
| - name: stop reflector |
| command: python /root/fusion_controller.py --stop-reflector --controller-ip "{{ controller_ip }}" |
| when: is_reflector == False |
| |
| - name: stop initiator |
| command: python /root/fusion_controller.py --stop-initiator --controller-ip "{{ controller_ip }}" |
| when: is_initiator == False |