| Srikanth Vavilapalli | a399315 | 2016-11-17 03:19:00 +0000 | [diff] [blame] | 1 | --- |
| 2 | - hosts: {{ instance_name }} |
| 3 | #gather_facts: False |
| 4 | connection: ssh |
| 5 | user: ubuntu |
| Sapan Bhatia | b4b2439 | 2017-02-07 11:32:55 -0800 | [diff] [blame] | 6 | become: yes |
| Srikanth Vavilapalli | a399315 | 2016-11-17 03:19:00 +0000 | [diff] [blame] | 7 | vars: |
| 8 | target_subnet : {{ target_subnet }} |
| 9 | src_intf_ip : {{ src_intf_ip }} |
| 10 | |
| 11 | |
| 12 | tasks: |
| 13 | - name: Find the interface that has specified src ip |
| 14 | shell: ifconfig | grep -B1 {{ src_intf_ip }} | head -n1 | awk '{print $1}' |
| 15 | register: src_intf |
| 16 | |
| 17 | - name: debug |
| 18 | debug: var=src_intf.stdout |
| 19 | |
| 20 | - name: set up the network |
| 21 | shell: "{{ '{{' }} item {{ '}}' }}" |
| 22 | with_items: |
| 23 | - sudo ip route add {{ target_subnet }} dev {{ '{{' }} src_intf.stdout {{ '}}' }} |
| 24 | |