summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/setup-network
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/adapters/ansible/roles/setup-network')
-rw-r--r--deploy/adapters/ansible/roles/setup-network/tasks/main.yml24
-rw-r--r--deploy/adapters/ansible/roles/setup-network/templates/my_configs.debian14
2 files changed, 18 insertions, 20 deletions
diff --git a/deploy/adapters/ansible/roles/setup-network/tasks/main.yml b/deploy/adapters/ansible/roles/setup-network/tasks/main.yml
index 94816044..8df1ac3a 100644
--- a/deploy/adapters/ansible/roles/setup-network/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/setup-network/tasks/main.yml
@@ -15,24 +15,24 @@
when: 'item["type"] == "ovs"'
- name: setup sys intf
- shell: ip link del {{ item["name"] }}; \
- ip link add link {{ item["interface"] }} name {{ item["name"] }} type vlan id {{ item["vlan_tag"] }}; \
- ip link set {{ item["interface"] }} up
- when: '"vlan_tag" in item'
- with_items: "{{ network_cfg['sys_intf_mappings'] }}"
+ shell: ip link del {{ item.key }}; \
+ ip link add link {{ item.value["interface"] }} name {{ item.key }} type vlan id {{ item.value["vlan_tag"] }}; \
+ ip link set {{ item.value["interface"] }} up
+ when: '"vlan_tag" in item.value and item.value["type"] == "vlan"'
+ with_dict: "{{ sys_intf_mappings }}"
- name: set sys intf ip
- shell: ip addr del {{ item["ip"] }}/{{ item["netmask"] }} dev {{ item["alias"] }}; \
- ip addr add {{ item["ip"] }}/{{ item["netmask"] }} dev {{ item["alias"] }}; \
- ip link set {{ item["alias"] }} up
- with_items: "{{ host_ip_settings }}"
+ shell: ip addr del {{ item.value["ip"] }}/{{ item.value["netmask"] }} dev {{ item.value["alias"] }}; \
+ ip addr add {{ item.value["ip"] }}/{{ item.value["netmask"] }} dev {{ item.value["alias"] }}; \
+ ip link set {{ item.value["alias"] }} up
+ with_dict: "{{ host_ip_settings }}"
- name: set gateway
shell: ip route del default; \
- ip route add default via {{ item["gw"] }} dev {{ item["alias"] }}
- when: '"gw" in item'
- with_items: "{{ host_ip_settings }}"
+ ip route add default via {{ item.value["gw"] }} dev {{ item.key }}
+ when: '"gw" in item.value'
+ with_dict: "{{ host_ip_settings }}"
- name: copy net config
template: src=my_configs.debian dest=/etc/network/interfaces.d/my_configs.cfg
diff --git a/deploy/adapters/ansible/roles/setup-network/templates/my_configs.debian b/deploy/adapters/ansible/roles/setup-network/templates/my_configs.debian
index 54031ed4..5ab1519b 100644
--- a/deploy/adapters/ansible/roles/setup-network/templates/my_configs.debian
+++ b/deploy/adapters/ansible/roles/setup-network/templates/my_configs.debian
@@ -1,16 +1,14 @@
-{%- for intf in host_ip_settings %}
+{%- for alias, intf in host_ip_settings.items() %}
-auto {{ intf["alias"] }}
-iface {{ intf["alias"] }} inet static
+auto {{ alias }}
+iface {{ alias }} inet static
address {{ intf["ip"] }}
netmask {{ intf["netmask"] }}
{% if "gw" in intf %}
gateway {{ intf["gw"] }}
{% endif %}
-{% for sys_intf in network_cfg["sys_intf_mappings"] %}
-{% if "vlan_tag" in sys_intf and sys_intf["name"] == intf["alias"] %}
- pre-up ip link set {{ sys_intf["interface"] }} up
- pre-up ip link add link {{ sys_intf["interface"] }} name {{ sys_intf["name"] }} type vlan id {{ sys_intf["vlan_tag"] }}
+{% if intf["name"] == alias %}
+ pre-up ip link set {{ sys_intf_mappings[alias]["interface"] }} up
+ pre-up ip link add link {{ sys_intf_mappings[alias]["interface"] }} name {{ alias }} type vlan id {{ sys_intf_mappings[alias]["vlan_tag"] }}
{% endif %}
{% endfor %}
-{% endfor %}