vm/network: ubuntu bionic uses netplan...
authorChristian Pointner <equinox@realraum.at>
Wed, 28 Nov 2018 00:40:14 +0000 (01:40 +0100)
committerChristian Pointner <equinox@realraum.at>
Wed, 28 Nov 2018 00:40:14 +0000 (01:40 +0100)
ansible/roles/vm/network/tasks/classic.yml [new file with mode: 0644]
ansible/roles/vm/network/tasks/main.yml
ansible/roles/vm/network/tasks/netplan.yml [new file with mode: 0644]
ansible/vm-install.yml

diff --git a/ansible/roles/vm/network/tasks/classic.yml b/ansible/roles/vm/network/tasks/classic.yml
new file mode 100644 (file)
index 0000000..4728bf4
--- /dev/null
@@ -0,0 +1,26 @@
+---
+- block:
+    - name: remove legacy systemd.link units
+      with_items:
+        - 50-virtio-kernel-names.link
+        - 99-default.link
+      file:
+        name: "/etc/systemd/network/{{ item }}"
+        state: absent
+
+    - name: install systemd network link units
+      with_items: "{{ network.systemd_link.interfaces }}"
+      loop_control:
+        index_var: interface_index
+      template:
+        src: systemd.link.j2
+        dest: "/etc/systemd/network/{{ '%02d' | format(interface_index + 11) }}-{{ item.name }}.link"
+      notify: rebuild initramfs
+
+  when: network.systemd_link is defined
+
+- name: install basic interface config
+  template:
+    src: interfaces.j2
+    dest: /etc/network/interfaces
+    mode: 0644
index 39f4ff4..0171d11 100644 (file)
@@ -1,29 +1,11 @@
 ---
-- block:
-    - name: remove legacy systemd.link units
-      with_items:
-        - 50-virtio-kernel-names.link
-        - 99-default.link
-      file:
-        name: "/etc/systemd/network/{{ item }}"
-        state: absent
+- name: install classic network config
+  import_tasks: classic.yml
+  when: ansible_distribution == "Debian" or (ansible_distribution == "Ubuntu" and (ansible_distribution_major_version | int) < 18)
 
-    - name: install systemd network link units
-      with_items: "{{ network.systemd_link.interfaces }}"
-      loop_control:
-        index_var: interface_index
-      template:
-        src: systemd.link.j2
-        dest: "/etc/systemd/network/{{ '%02d' | format(interface_index + 11) }}-{{ item.name }}.link"
-      notify: rebuild initramfs
-
-  when: network.systemd_link is defined
-
-- name: install basic interface config
-  template:
-    src: interfaces.j2
-    dest: /etc/network/interfaces
-    mode: 0644
+- name: install basic netplan config
+  import_tasks: netplan.yml
+  when:  ansible_distribution == "Ubuntu" and (ansible_distribution_major_version | int) >= 18
 
 - name: remove resolvconf package
   apt:
diff --git a/ansible/roles/vm/network/tasks/netplan.yml b/ansible/roles/vm/network/tasks/netplan.yml
new file mode 100644 (file)
index 0000000..0adf9f5
--- /dev/null
@@ -0,0 +1,3 @@
+---
+- debug:
+    msg: "TODO ******* ADD ME ********"
index 32166e7..c244aa9 100644 (file)
@@ -39,6 +39,9 @@
 
 - name: Apply VM configuration roles
   hosts: "{{ hostname }}"
+  pre_tasks:
+  - name: make sure to update cached facts
+    setup:
   roles:
   - role: vm/grub
   - role: vm/network