From 66c36c489620deff6280e8fa50dc658b49ff0d3f Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Wed, 27 Jun 2018 20:04:45 +0200 Subject: [PATCH] common: fix network interfaces names (ensXX -> ethX) in consistent way with systems upgraded from debian 8 --- roles/common/files/50-virtio-kernel-names.link | 10 ++++++++++ roles/common/files/99-default.link | 6 ++++++ roles/common/tasks/Debian.yml | 9 +++++++++ 3 files changed, 25 insertions(+) create mode 100644 roles/common/files/50-virtio-kernel-names.link create mode 100644 roles/common/files/99-default.link diff --git a/roles/common/files/50-virtio-kernel-names.link b/roles/common/files/50-virtio-kernel-names.link new file mode 100644 index 0000000..f39f26b --- /dev/null +++ b/roles/common/files/50-virtio-kernel-names.link @@ -0,0 +1,10 @@ +# udev 226 introduced predictable interface names for virtio; +# disable this for upgrades. You can remove this file if you update your +# network configuration to move to the ens* names instead. +# See /usr/share/doc/udev/README.Debian.gz for details about predictable +# network interface names. +[Match] +Driver=virtio_net + +[Link] +NamePolicy=onboard kernel diff --git a/roles/common/files/99-default.link b/roles/common/files/99-default.link new file mode 100644 index 0000000..e156606 --- /dev/null +++ b/roles/common/files/99-default.link @@ -0,0 +1,6 @@ +# This machine is most likely a virtualized guest, where the old persistent +# network interface mechanism (75-persistent-net-generator.rules) did not work. +# This file disables /lib/systemd/network/99-default.link to avoid +# changing network interface names on upgrade. Please read +# /usr/share/doc/udev/README.Debian.gz about how to migrate to the currently +# supported mechanism. diff --git a/roles/common/tasks/Debian.yml b/roles/common/tasks/Debian.yml index 916fc57..41b3ba3 100644 --- a/roles/common/tasks/Debian.yml +++ b/roles/common/tasks/Debian.yml @@ -63,6 +63,15 @@ copy: src=resume dest=/etc/initramfs-tools/conf.d/resume notify: update-initramfs +# TODO template /etc/network/interfaces + +- name: Fix network interface names + copy: src={{ item }} dest=/etc/systemd/network/{{ item }} + with_items: + - 50-virtio-kernel-names.link + - 99-default.link + notify: update-initramfs + - name: Prevent normal users from running su lineinfile: path: /etc/pam.d/su