summaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
Diffstat (limited to 'roles')
-rw-r--r--roles/preseed/defaults/main.yml2
-rw-r--r--roles/preseed/tasks/main.yml19
-rw-r--r--roles/preseed/templates/preseed_debian-buster.cfg.j212
-rw-r--r--roles/preseed/templates/preseed_debian-stretch.cfg.j212
-rw-r--r--roles/preseed/templates/preseed_ubuntu-bionic.cfg.j212
-rw-r--r--roles/preseed/templates/preseed_ubuntu-xenial.cfg.j212
-rw-r--r--roles/preseed/templates/preseed_xubuntu-cosmic-desktop-with-raid.cfg.j219
-rw-r--r--roles/vm/install/tasks/main.yml3
8 files changed, 74 insertions, 17 deletions
diff --git a/roles/preseed/defaults/main.yml b/roles/preseed/defaults/main.yml
new file mode 100644
index 00000000..b120f133
--- /dev/null
+++ b/roles/preseed/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+#preseed_force_net_ifnames_policy: path
diff --git a/roles/preseed/tasks/main.yml b/roles/preseed/tasks/main.yml
index 8e00fb82..33248b94 100644
--- a/roles/preseed/tasks/main.yml
+++ b/roles/preseed/tasks/main.yml
@@ -17,6 +17,21 @@
path: "{{ preseed_tmpdir }}/authorized_keys"
key: "{{ ssh_keys_root | join('\n') }}"
+- name: force net interface name policy
+ when: preseed_force_net_ifnames_policy is defined
+ block:
+ - name: prepare directories to force network interface name policy
+ file:
+ path: "{{ preseed_tmpdir }}/etc/systemd/network"
+ state: directory
+
+ - name: install link unit to force network interface name policy
+ copy:
+ dest: "{{ preseed_tmpdir }}/etc/systemd/network/90-namepolicy.link"
+ content: |
+ [Link]
+ NamePolicy={{ preseed_force_net_ifnames_policy }}
+
- name: Inject files into initramfs
shell: cpio -H newc -o | gzip -9 >> 'initrd.preseed.gz'
args:
@@ -24,5 +39,9 @@
stdin: |
preseed.cfg
authorized_keys
+ etc/
+ etc/systemd/
+ etc/systemd/network/
+ etc/systemd/network/90-namepolicy.link
tags:
- skip_ansible_lint
diff --git a/roles/preseed/templates/preseed_debian-buster.cfg.j2 b/roles/preseed/templates/preseed_debian-buster.cfg.j2
index 6e9f4e47..4c458c36 100644
--- a/roles/preseed/templates/preseed_debian-buster.cfg.j2
+++ b/roles/preseed/templates/preseed_debian-buster.cfg.j2
@@ -134,8 +134,14 @@ d-i preseed/late_command string \
in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \
in-target bash -c "passwd -d root && passwd -l root"; \
in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \
- mkdir -p -m 0700 /target/root/.ssh; \
- cp /authorized_keys /target/root/.ssh/; \
+{% if preseed_force_net_ifnames_policy is defined %}
+ mkdir -p /target/etc/systemd/network; \
+ in-target bash -c "echo '[Link]' > /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "echo 'NamePolicy={{ preseed_force_net_ifnames_policy }}' >> /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "update-initramfs -u"; \
+{% endif %}
{% if hostvars[hostname].ansible_port is defined %}
- in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"
+ in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \
{% endif %}
+ mkdir -p -m 0700 /target/root/.ssh; \
+ cp /authorized_keys /target/root/.ssh/
diff --git a/roles/preseed/templates/preseed_debian-stretch.cfg.j2 b/roles/preseed/templates/preseed_debian-stretch.cfg.j2
index 69a6ca5b..7de73ded 100644
--- a/roles/preseed/templates/preseed_debian-stretch.cfg.j2
+++ b/roles/preseed/templates/preseed_debian-stretch.cfg.j2
@@ -134,8 +134,14 @@ d-i preseed/late_command string \
in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \
in-target bash -c "passwd -d root && passwd -l root"; \
in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \
- mkdir -p -m 0700 /target/root/.ssh; \
- cp /authorized_keys /target/root/.ssh/; \
+{% if preseed_force_net_ifnames_policy is defined %}
+ mkdir -p /target/etc/systemd/network; \
+ in-target bash -c "echo '[Link]' > /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "echo 'NamePolicy={{ preseed_force_net_ifnames_policy }}' >> /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "update-initramfs -u"; \
+{% endif %}
{% if hostvars[hostname].ansible_port is defined %}
- in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"
+ in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \
{% endif %}
+ mkdir -p -m 0700 /target/root/.ssh; \
+ cp /authorized_keys /target/root/.ssh/
diff --git a/roles/preseed/templates/preseed_ubuntu-bionic.cfg.j2 b/roles/preseed/templates/preseed_ubuntu-bionic.cfg.j2
index f4b0fff1..5fcab0aa 100644
--- a/roles/preseed/templates/preseed_ubuntu-bionic.cfg.j2
+++ b/roles/preseed/templates/preseed_ubuntu-bionic.cfg.j2
@@ -141,8 +141,14 @@ d-i preseed/late_command string \
in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \
in-target bash -c "passwd -d root && passwd -l root"; \
in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \
- mkdir -p -m 0700 /target/root/.ssh; \
- cp /authorized_keys /target/root/.ssh/; \
+{% if preseed_force_net_ifnames_policy is defined %}
+ mkdir -p /target/etc/systemd/network; \
+ in-target bash -c "echo '[Link]' > /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "echo 'NamePolicy={{ preseed_force_net_ifnames_policy }}' >> /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "update-initramfs -u"; \
+{% endif %}
{% if hostvars[hostname].ansible_port is defined %}
- in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"
+ in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \
{% endif %}
+ mkdir -p -m 0700 /target/root/.ssh; \
+ cp /authorized_keys /target/root/.ssh/
diff --git a/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2 b/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2
index 7d053a5d..2096c757 100644
--- a/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2
+++ b/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2
@@ -140,8 +140,14 @@ d-i preseed/late_command string \
in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \
in-target bash -c "passwd -d root && passwd -l root"; \
in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \
- mkdir -p -m 0700 /target/root/.ssh; \
- cp /authorized_keys /target/root/.ssh/; \
+{% if preseed_force_net_ifnames_policy is defined %}
+ mkdir -p /target/etc/systemd/network; \
+ in-target bash -c "echo '[Link]' > /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "echo 'NamePolicy={{ preseed_force_net_ifnames_policy }}' >> /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "update-initramfs -u"; \
+{% endif %}
{% if hostvars[hostname].ansible_port is defined %}
- in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"
+ in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \
{% endif %}
+ mkdir -p -m 0700 /target/root/.ssh; \
+ cp /authorized_keys /target/root/.ssh/
diff --git a/roles/preseed/templates/preseed_xubuntu-cosmic-desktop-with-raid.cfg.j2 b/roles/preseed/templates/preseed_xubuntu-cosmic-desktop-with-raid.cfg.j2
index 13c30e93..ac4f8bde 100644
--- a/roles/preseed/templates/preseed_xubuntu-cosmic-desktop-with-raid.cfg.j2
+++ b/roles/preseed/templates/preseed_xubuntu-cosmic-desktop-with-raid.cfg.j2
@@ -16,14 +16,19 @@ d-i console-setup/ask_detect boolean false
d-i hw-detect/load_firmware boolean false
-d-i netcfg/disable_dhcp boolean true
d-i netcfg/choose_interface select {{ install_interface | default(hostvars[hostname].network_cooked.primary.interface) }}
+{% if 'install_dhcp' in hostvars[hostname] and hostvars[hostname].install_dhcp %}
+d-i netcfg/disable_dhcp boolean false
d-i netcfg/disable_autoconfig boolean false
+{% else %}
+d-i netcfg/disable_dhcp boolean true
+d-i netcfg/disable_autoconfig boolean true
d-i netcfg/get_ipaddress string {{ hostvars[hostname].network_cooked.primary.ip }}
d-i netcfg/get_netmask string {{ hostvars[hostname].network_cooked.primary.mask }}
d-i netcfg/get_gateway string {{ hostvars[hostname].network_cooked.primary.gateway }}
d-i netcfg/get_nameservers string {{ hostvars[hostname].network_cooked.nameservers | join(' ') }}
d-i netcfg/confirm_static boolean true
+{% endif %}
d-i netcfg/hostname string {{ hostvars[hostname].host_name }}
d-i netcfg/get_hostname string {{ hostvars[hostname].host_name }}
@@ -142,8 +147,14 @@ d-i preseed/late_command string \
in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \
in-target bash -c "passwd -d root && passwd -l root"; \
in-target bash -c "sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces"; \
- mkdir -p -m 0700 /target/root/.ssh; \
- cp /authorized_keys /target/root/.ssh/; \
+{% if preseed_force_net_ifnames_policy is defined %}
+ mkdir -p /target/etc/systemd/network; \
+ in-target bash -c "echo '[Link]' > /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "echo 'NamePolicy={{ preseed_force_net_ifnames_policy }}' >> /etc/systemd/network/90-namepolicy.link"; \
+ in-target bash -c "update-initramfs -u"; \
+{% endif %}
{% if hostvars[hostname].ansible_port is defined %}
- in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"
+ in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config"; \
{% endif %}
+ mkdir -p -m 0700 /target/root/.ssh; \
+ cp /authorized_keys /target/root/.ssh/
diff --git a/roles/vm/install/tasks/main.yml b/roles/vm/install/tasks/main.yml
index e7e5cf1a..9caa88c8 100644
--- a/roles/vm/install/tasks/main.yml
+++ b/roles/vm/install/tasks/main.yml
@@ -19,8 +19,9 @@
name: preseed
vars:
ssh_keys_root: "{{ hostvars[hostname].ssh_keys_root }}"
- install_interface: enp1s1
preseed_tmpdir: "{{ tmpdir.path }}"
+ preseed_force_net_ifnames_policy: path
+ install_interface: enp1s1
- name: Make preseed workdir readable by qemu
acl: