From 4f30f1583de913c011a6c6a40e53f2e4855eb489 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Thu, 6 Dec 2018 20:10:37 +0100 Subject: debian: networkd: add networkd-wait-online support --- roles/debian/defaults/main.yml | 1 + roles/debian/tasks/networkd.yml | 31 ++++++++++++++++++++++++++ roles/debian/templates/networkd-ignore.conf.j2 | 6 +++++ 3 files changed, 38 insertions(+) create mode 100644 roles/debian/templates/networkd-ignore.conf.j2 (limited to 'roles/debian') 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 %} -- cgit v1.2.1