aboutsummaryrefslogtreecommitdiffstats
path: root/roles/debian
diff options
context:
space:
mode:
authorEmil Renner Berthing <esmil@labitat.dk>2018-12-06 20:10:37 +0100
committerEmil Renner Berthing <esmil@labitat.dk>2018-12-06 20:10:37 +0100
commit4f30f1583de913c011a6c6a40e53f2e4855eb489 (patch)
tree5ec3c245a50327f22de823a99b640ab918d67c17 /roles/debian
parentc624e52a8357da8db022831b86f2c85bb7bfed2f (diff)
downloadlabitat-ansible-4f30f1583de913c011a6c6a40e53f2e4855eb489.tar.gz
labitat-ansible-4f30f1583de913c011a6c6a40e53f2e4855eb489.tar.xz
labitat-ansible-4f30f1583de913c011a6c6a40e53f2e4855eb489.zip
debian: networkd: add networkd-wait-online support
Diffstat (limited to 'roles/debian')
-rw-r--r--roles/debian/defaults/main.yml1
-rw-r--r--roles/debian/tasks/networkd.yml31
-rw-r--r--roles/debian/templates/networkd-ignore.conf.j26
3 files changed, 38 insertions, 0 deletions
diff --git a/roles/debian/defaults/main.yml b/roles/debian/defaults/main.yml
index cb79ddc..057f612 100644
--- a/roles/debian/defaults/main.yml
+++ b/roles/debian/defaults/main.yml
@@ -14,6 +14,7 @@ systemd_conf: {}
journald_conf: {}
logind_conf: {}
resolved_conf: {}
+networkd_ignore: []
timesyncd_conf: {}
apt_preferences: {}
diff --git a/roles/debian/tasks/networkd.yml b/roles/debian/tasks/networkd.yml
index 4dac677..967dace 100644
--- a/roles/debian/tasks/networkd.yml
+++ b/roles/debian/tasks/networkd.yml
@@ -12,6 +12,37 @@
command: "systemctl {{ use_networkd|ternary('enable','disable') }} systemd-networkd.service"
when: chroot
+# in Debian 9 (stretch) we need to enable this manually
+# this is fixed in buster though
+- name: Enable/disable systemd-networkd-wait-online
+ systemd:
+ name: systemd-networkd-wait-online.service
+ enabled: "{{ use_networkd|ternary('yes','no') }}"
+ masked: no
+ when: ansible_distribution_release == 'stretch' and not chroot
+- name: '- when in chroot'
+ command: "systemctl {{ use_networkd|ternary('enable','disable') }} systemd-networkd-wait-online.service"
+ when: ansible_distribution_release == 'stretch' and chroot
+
+# use RequiredForOnline in systemd.network files if possible,
+# but for older systemd's set networkd_ignore: ['eth0', 'eth1']
+- name: Create/remove /etc/systemd/system/systemd-networkd-wait-online.service.d
+ file:
+ dest: '/etc/systemd/system/systemd-networkd-wait-online.service.d'
+ state: "{{ (networkd_ignore|length > 0)|ternary('directory','absent') }}"
+ owner: root
+ group: root
+ mode: 0755
+- name: Don't wait for certain interfaces
+ template:
+ dest: '/etc/systemd/system/systemd-networkd-wait-online.service.d/ignore.conf'
+ src: networkd-ignore.conf.j2
+ owner: root
+ group: root
+ mode: 0644
+ when: networkd_ignore|length > 0
+
+# if we use networkd, make sure the networking service is disabled
- name: Mask Debian networking.service
systemd:
name: networking.service
diff --git a/roles/debian/templates/networkd-ignore.conf.j2 b/roles/debian/templates/networkd-ignore.conf.j2
new file mode 100644
index 0000000..855cd7b
--- /dev/null
+++ b/roles/debian/templates/networkd-ignore.conf.j2
@@ -0,0 +1,6 @@
+[Service]
+ExecStart=
+ExecStart=/lib/systemd/systemd-networkd-wait-online
+{%- for iface in networkd_ignore %}
+ --ignore {{ iface }}
+{%- endfor %}