blob: 346e2f34d6a1b4b2d6a19983759f5037e01d5db4 [file] [log] [blame]
Luca Prete8d4e8bc2016-08-24 14:49:54 -07001---
2#
3# Configures networking and Linux brdiges
4#
5- name: Creating ONOS bridge
alshabib4997cd72016-05-24 22:48:29 -07006 become: yes
7 template:
8 src: templates/create_bridge.j2
Luca Prete8d4e8bc2016-08-24 14:49:54 -07009 dest: "/etc/network/if-pre-up.d/create_bridge_{{ bridge.name }}"
alshabib4997cd72016-05-24 22:48:29 -070010 owner: root
11 group: root
12 mode: 0755
13
Luca Prete8d4e8bc2016-08-24 14:49:54 -070014- name: Adding second NIC to ONOS bridge
alshabib4997cd72016-05-24 22:48:29 -070015 become: yes
16 template:
17 src: templates/add_iface.j2
Luca Prete8d4e8bc2016-08-24 14:49:54 -070018 dest: "/etc/network/if-pre-up.d/add_iface_{{ bridge.phy_interface }}"
alshabib4997cd72016-05-24 22:48:29 -070019 owner: root
20 group: root
21 mode: 0755
22
Luca Prete8d4e8bc2016-08-24 14:49:54 -070023- name: Activating ONOS bridge
alshabib4997cd72016-05-24 22:48:29 -070024 become: yes
Luca Prete8d4e8bc2016-08-24 14:49:54 -070025 command: /etc/network/if-pre-up.d/create_bridge_{{ bridge.name }} report-changed
alshabib4997cd72016-05-24 22:48:29 -070026 register: bridge_changed
27 changed_when: bridge_changed.stdout == 'true'
28
Luca Prete8d4e8bc2016-08-24 14:49:54 -070029- name: Adding physical interface to the bridge
alshabib4997cd72016-05-24 22:48:29 -070030 become: yes
Luca Prete8d4e8bc2016-08-24 14:49:54 -070031 command: /etc/network/if-pre-up.d/add_iface_{{ bridge.phy_interface }} report-changed
alshabib4997cd72016-05-24 22:48:29 -070032 register: bridge_iface_changed
33 changed_when: bridge_iface_changed == 'true'
34
Luca Prete8d4e8bc2016-08-24 14:49:54 -070035- name: Moving the IP and starting bridge automatically at startup
alshabib4997cd72016-05-24 22:48:29 -070036 become: yes
Luca Prete8d4e8bc2016-08-24 14:49:54 -070037 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 }}"
alshabib4997cd72016-05-24 22:48:29 -070047
Luca Prete8d4e8bc2016-08-24 14:49:54 -070048- name: Configuring the IP on the bridge
alshabib4997cd72016-05-24 22:48:29 -070049 become: yes
Luca Prete8d4e8bc2016-08-24 14:49:54 -070050 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"