| --- |
| |
| - 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: get interface of public_ip |
| register: public_interface |
| shell: | |
| ip addr | awk '/^[0-9]+:/ { sub(/:/,"",$2); iface=$2 } /^[[:space:]]*inet / { split($2, a, "/"); print iface" : "a[1] }' | grep "{{ public_ip }}" | cut -d " " -f 1 |
| when: result.stat.exists == False |
| |
| - name: get gateway of private_ip |
| register: private_gateway |
| shell: | |
| echo {{ private_ip }} | cut -d '.' -f 1,2,3 | sed '/.*/ s/$/.1/' |
| when: result.stat.exists == False |
| |
| - name: setup vta |
| shell: | |
| vnf-setup --test-network {{private_interface.stdout}},{{private_ip}},255.255.255.0,{{private_gateway.stdout}} --management-interface {{public_interface.stdout}} --io-virtualization VIRTIO --test-speed 1G --tagging UNTAGGED --mtu-size 1450 --controller-address {{ controller_ip }} |
| when: result.stat.exists == False |
| |
| - name: record task completed |
| shell: echo "done" > /tmp/init_completed |
| |
| - name: restart vta |
| shell: reboot |
| when: result.stat.exists == False |
| |