From 911edf13676a9028d2c5c893248c9a1bde1dfa09 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 16 Jul 2019 21:50:51 +0200 Subject: final tests with net ifname namepolicy succeeded --- chaos-at-home/ch-testvm.yml | 7 +++++ install.sh | 4 +++ inventory/host_vars/ch-atlas.yml | 1 + inventory/host_vars/ch-testvm.yml | 33 ++++++++++++++++++++++ inventory/hosts.ini | 4 ++- .../templates/preseed_debian-stretch.cfg.j2 | 12 ++++++-- .../preseed/templates/preseed_ubuntu-bionic.cfg.j2 | 12 ++++++-- .../preseed/templates/preseed_ubuntu-xenial.cfg.j2 | 12 ++++++-- ...preseed_xubuntu-cosmic-desktop-with-raid.cfg.j2 | 19 ++++++++++--- 9 files changed, 90 insertions(+), 14 deletions(-) create mode 100644 chaos-at-home/ch-testvm.yml create mode 100644 inventory/host_vars/ch-testvm.yml diff --git a/chaos-at-home/ch-testvm.yml b/chaos-at-home/ch-testvm.yml new file mode 100644 index 00000000..c10c8b57 --- /dev/null +++ b/chaos-at-home/ch-testvm.yml @@ -0,0 +1,7 @@ +--- +- name: Basic Setup + hosts: ch-testvm + roles: + - role: base + - role: sshd + - role: zsh diff --git a/install.sh b/install.sh index d60cc56e..b4f2c187 100755 --- a/install.sh +++ b/install.sh @@ -23,5 +23,9 @@ echo "########## clearing old ssh host keys #########" ./remove-known-host.sh "$name" echo "" +echo "########## removing cached facts #########" +rm -f ".cache/facts/$name" +echo "" + echo "######## running the install playbook ########" exec ansible-playbook -e "hostname=$name" -e "install_distro=$distro" -e "install_codename=$codename" -e "hostenv=$env_group" $@ "$env_group/$(basename "$0" .sh).yml" diff --git a/inventory/host_vars/ch-atlas.yml b/inventory/host_vars/ch-atlas.yml index d59ed529..a131434a 100644 --- a/inventory/host_vars/ch-atlas.yml +++ b/inventory/host_vars/ch-atlas.yml @@ -10,4 +10,5 @@ vm_host: - 89.106.208.12 offsets: ch-keyserver: 3 + ch-testvm: 4 r3-vex2: 11 diff --git a/inventory/host_vars/ch-testvm.yml b/inventory/host_vars/ch-testvm.yml new file mode 100644 index 00000000..ab2faf95 --- /dev/null +++ b/inventory/host_vars/ch-testvm.yml @@ -0,0 +1,33 @@ +--- +apt_repo_provider: ffgraz + +vm_host: ch-atlas + +install: + host: "{{ vm_host }}" + mem: 1024 + numcpu: 1 + disks: + primary: /dev/sda + scsi: + sda: + vg: "{{ hostvars[vm_host].host_name }}" + lv: "{{ inventory_hostname }}" + size: 5g + interfaces: + - bridge: extbr + name: primary0 + autostart: True + +network: + nameservers: "{{ hostvars[vm_host].vm_host.network.dns }}" + domain: "{{ host_domain }}" + systemd_link: + interfaces: "{{ install.interfaces }}" + primary: + interface: primary0 + ip: "{{ hostvars[vm_host].vm_host.network.prefix | ipaddr(hostvars[vm_host].vm_host.network.offsets[inventory_hostname]) | ipaddr('address') }}" + mask: "{{ hostvars[vm_host].vm_host.network.prefix | ipaddr('netmask') }}" + gateway: "{{ hostvars[vm_host].vm_host.network.gw }}" + prefix6: "{{ hostvars[vm_host].vm_host.network.prefix6 | ipaddr(hostvars[vm_host].vm_host.network.offsets[inventory_hostname]) | ipaddr('address/prefix') }}" + gateway6: "{{ hostvars[vm_host].vm_host.network.gw6 }}" diff --git a/inventory/hosts.ini b/inventory/hosts.ini index 87a51a43..048283a9 100644 --- a/inventory/hosts.ini +++ b/inventory/hosts.ini @@ -16,8 +16,9 @@ ansible_port=222 [chaos_at_home] ch-atlas host_name=atlas -ch-keyserver host_name=keyserver ch-pan host_name=pan +ch-keyserver host_name=keyserver +ch-testvm host_name=testvm ch-gnocchi host_name=gnocchi ch-router host_name=router ch-gw-lan host_name=gw-lan @@ -161,6 +162,7 @@ ch-gnocchi emc-stats emc-master ch-keyserver +ch-testvm ch-gw-lan ch-jump r3-vex2 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/ -- cgit v1.2.3