aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/setup-network/tasks/main.yml
blob: 8df1ac3a5d8d41b56d0723c4acc74d2fa8705a2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
- name: add ovs bridge
  openvswitch_bridge: bridge={{ item["name"] }} state=present
  with_items: "{{ network_cfg['provider_net_mappings'] }}"
  when: 'item["type"] == "ovs"'

- name: add ovs uplink
  openvswitch_port: bridge={{ item["name"] }} port={{ item["interface"] }} state=present
  with_items: "{{ network_cfg['provider_net_mappings'] }}"
  when: 'item["type"] == "ovs"'

- name: add ovs uplink
  shell: ip link set {{ item["interface"] }} up
  with_items: "{{ network_cfg['provider_net_mappings'] }}"
  when: 'item["type"] == "ovs"'

- name: setup sys intf
  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.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.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
  when: ansible_os_family == "Debian"

- name: source net config
  lineinfile: dest=/etc/network/interfaces line='source /etc/network/interfaces.d/my_configs.cfg'
  when: ansible_os_family == "Debian"