Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 1 | --- |
| 2 | # |
| 3 | # Configures networking and Linux brdiges |
| 4 | # |
| 5 | - name: Creating ONOS bridge |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 6 | become: yes |
| 7 | template: |
| 8 | src: templates/create_bridge.j2 |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 9 | dest: "/etc/network/if-pre-up.d/create_bridge_{{ bridge.name }}" |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 10 | owner: root |
| 11 | group: root |
| 12 | mode: 0755 |
| 13 | |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 14 | - name: Adding second NIC to ONOS bridge |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 15 | become: yes |
| 16 | template: |
| 17 | src: templates/add_iface.j2 |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 18 | dest: "/etc/network/if-pre-up.d/add_iface_{{ bridge.phy_interface }}" |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 19 | owner: root |
| 20 | group: root |
| 21 | mode: 0755 |
| 22 | |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 23 | - name: Activating ONOS bridge |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 24 | become: yes |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 25 | command: /etc/network/if-pre-up.d/create_bridge_{{ bridge.name }} report-changed |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 26 | register: bridge_changed |
| 27 | changed_when: bridge_changed.stdout == 'true' |
| 28 | |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 29 | - name: Adding physical interface to the bridge |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 30 | become: yes |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 31 | command: /etc/network/if-pre-up.d/add_iface_{{ bridge.phy_interface }} report-changed |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 32 | register: bridge_iface_changed |
| 33 | changed_when: bridge_iface_changed == 'true' |
| 34 | |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 35 | - name: Moving the IP and starting bridge automatically at startup |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 36 | become: yes |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 37 | template: |
| 38 | src: templates/post_ifup.j2 |
| 39 | dest: "/etc/network/if-up.d/bring_up_{{ bridge.name }}" |
| 40 | owner: root |
| 41 | group: root |
| 42 | mode: 0755 |
| 43 | |
| 44 | - name: Removing IP from the second NIC |
| 45 | become: yes |
| 46 | command: "/sbin/ip addr flush {{ bridge.phy_interface }}" |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 47 | |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 48 | - name: Configuring the IP on the bridge |
alshabib | 4997cd7 | 2016-05-24 22:48:29 -0700 | [diff] [blame] | 49 | become: yes |
Luca Prete | 8d4e8bc | 2016-08-24 14:49:54 -0700 | [diff] [blame] | 50 | command: "/sbin/ifconfig {{ bridge.name }} inet {{ bridge.ip }}" |
| 51 | |
| 52 | - name: Bringing up ONOS bridge |
| 53 | become: yes |
| 54 | command: "/sbin/ifconfig {{ bridge.name }} up" |