Skip to content

Commit e994173

Browse files
authored
fix the external net creation failure (#40)
if the interface is already created with same ip it failing on the subsequent runs. now adding a check before creating the interface
1 parent 99a62c6 commit e994173

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ansible/roles/post/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
vars:
44
vlan_interface: "{{ iface_2 }}.{{ external_network_vlan_id }}"
55
shell: |
6-
ip link add link {{ iface_2 }} name {{ vlan_interface }} type vlan id {{ external_network_vlan_id }}
6+
ip link show {{ vlan_interface }} > /dev/null 2>&1 || ip link add link {{ iface_2 }} name {{ vlan_interface }} type vlan id {{ external_network_vlan_id }}
77
ip link set dev {{ iface_2 }} up
88
ip link set dev {{ vlan_interface }} up
9-
ip a a {{ external_net_gateway }}/{{ external_net_cidr.split('/')[1] }} dev {{ vlan_interface }}
9+
ip addr show dev {{ vlan_interface }} | grep -q "{{ external_net_gateway }}/{{ external_net_cidr.split('/')[1] }}" || ip a a {{ external_net_gateway }}/{{ external_net_cidr.split('/')[1] }} dev {{ vlan_interface }}
1010
become: true
1111

1212
- name: Create external network

0 commit comments

Comments
 (0)