added fixes for ansible 2.8
[noc.git] / ansible / roles / vm / network / tasks / main.yml
1 ---
2 - block:
3     - name: remove legacy systemd.link units
4       with_items:
5         - 50-virtio-kernel-names.link
6         - 99-default.link
7       file:
8         name: "/etc/systemd/network/{{ item }}"
9         state: absent
10
11     - name: install systemd network link units
12       with_items: "{{ network.systemd_link.interfaces }}"
13       loop_control:
14         index_var: interface_index
15       template:
16         src: systemd.link.j2
17         dest: "/etc/systemd/network/{{ '%02d' | format(interface_index + 11) }}-{{ item.name }}.link"
18       notify: rebuild initramfs
19
20   when: network.systemd_link is defined
21
22 - name: install basic interface config
23   template:
24     src: interfaces.j2
25     dest: /etc/network/interfaces
26     mode: 0644
27   when: ansible_distribution == "Debian" or (ansible_distribution == "Ubuntu" and (ansible_distribution_major_version | int) < 18)
28
29 - block:
30     - name: remove default netplan config
31       file:
32         path: /etc/netplan/01-netcfg.yaml
33         state: absent
34
35     - name: install basic netplan config
36       template:
37         src: netplan.yaml.j2
38         dest: "/etc/netplan/01-{{ network.primary.interface }}.yaml"
39         mode: 0644
40
41   when:  ansible_distribution == "Ubuntu" and (ansible_distribution_major_version | int) >= 18
42
43 - name: remove resolvconf package
44   apt:
45     name: resolvconf
46     state: absent
47     force_apt_get: yes
48     purge: yes
49
50 - name: generate resolv.conf
51   template:
52     src: resolv.conf.j2
53     dest: /etc/resolv.conf