From d8bcdc0341b0df29bd152e9b1f0eb3cb0e2b5439 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Wed, 11 Apr 2018 23:11:57 -0500 Subject: [PATCH] Update initramfs when links change In order to make the default link take effect initramfs needs to be updated. This change also updates the default link to use the recommended defaults from the systemd-networkd documentation. Default link config: - https://www.freedesktop.org/software/systemd/man/systemd.link.html#Examples See this thread for bug info: - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=793374 Change-Id: I5430da4acad1e36b7593ad6791afbebf9e730bba Signed-off-by: Kevin Carter --- handlers/main.yml | 3 +++ tasks/main.yml | 1 + templates/systemd-network-link.j2 | 1 + vars/redhat-7.yml | 2 ++ vars/suse-42.yml | 16 ++++++++++++++++ vars/ubuntu-16.04.yml | 16 ++++++++++++++++ 6 files changed, 39 insertions(+) create mode 100644 vars/suse-42.yml create mode 100644 vars/ubuntu-16.04.yml diff --git a/handlers/main.yml b/handlers/main.yml index 0d0ba9f..b335cfa 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -22,3 +22,6 @@ - systemd_run_networkd | bool tags: - systemd-networkd + +- name: Update initramfs + command: "{{ systemd_networkd_update_initramfs }}" diff --git a/tasks/main.yml b/tasks/main.yml index 869a5a5..32fd86b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -57,6 +57,7 @@ config_type: "ini" notify: - Restart systemd-networkd + - Update initramfs tags: - systemd-networkd diff --git a/templates/systemd-network-link.j2 b/templates/systemd-network-link.j2 index 99e55d9..147d224 100644 --- a/templates/systemd-network-link.j2 +++ b/templates/systemd-network-link.j2 @@ -1,4 +1,5 @@ # {{ ansible_managed }} [Link] +NamePolicy=kernel database onboard slot path MACAddressPolicy=persistent diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 2aaa301..637de9d 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -15,3 +15,5 @@ systemd_networkd_distro_packages: - systemd-networkd + +systemd_networkd_update_initramfs: "dracut -f" diff --git a/vars/suse-42.yml b/vars/suse-42.yml new file mode 100644 index 0000000..474d5ca --- /dev/null +++ b/vars/suse-42.yml @@ -0,0 +1,16 @@ +--- +# Copyright 2018, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +systemd_networkd_update_initramfs: "dracut -f" diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml new file mode 100644 index 0000000..1648a41 --- /dev/null +++ b/vars/ubuntu-16.04.yml @@ -0,0 +1,16 @@ +--- +# Copyright 2018, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +systemd_networkd_update_initramfs: "/usr/sbin/update-initramfs -u"