diff options
author | Christian Pointner <equinox@spreadspace.org> | 2019-12-26 23:25:02 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2019-12-26 23:25:02 +0100 |
commit | 74684fb93e26e2c9f37f699a84eb94acaf93c07a (patch) | |
tree | b514b605b934a6ee074a200e75f918ba05ad109e | |
parent | nextcloud: upgrade all instances and add occ script (diff) | |
parent | base role supports openbsd now too (diff) |
Merge branch 'topic/openbsd-test'
55 files changed, 452 insertions, 707 deletions
diff --git a/chaos-at-home/ch-atlas.yml b/chaos-at-home/ch-atlas.yml index 21c52da1..a1cd0b0c 100644 --- a/chaos-at-home/ch-atlas.yml +++ b/chaos-at-home/ch-atlas.yml @@ -5,4 +5,4 @@ - role: sshd - role: zsh - role: vm/host - - role: installer/debian + - role: installer/debian/base diff --git a/chaos-at-home/ch-gnocchi.yml b/chaos-at-home/ch-gnocchi.yml index 2ab51770..8a39ee19 100644 --- a/chaos-at-home/ch-gnocchi.yml +++ b/chaos-at-home/ch-gnocchi.yml @@ -6,8 +6,8 @@ - role: sshd - role: zsh - role: vm/host - - role: installer/debian - - role: installer/openbsd + - role: installer/debian/base + - role: installer/openbsd/base post_tasks: # you need to reboot for changes to take effect - name: install network interface config diff --git a/chaos-at-home/ch-router-obsd.yml b/chaos-at-home/ch-router-obsd.yml new file mode 100644 index 00000000..76b79316 --- /dev/null +++ b/chaos-at-home/ch-router-obsd.yml @@ -0,0 +1,7 @@ +--- +- name: Basic Setup + hosts: ch-router-obsd + roles: + - role: base + - role: sshd + - role: zsh diff --git a/common/vm-install.yml b/common/vm-install.yml index 36f2c4cc..cb3b86f0 100644 --- a/common/vm-install.yml +++ b/common/vm-install.yml @@ -52,8 +52,11 @@ setup: roles: - role: vm/grub + when: install_distro in ['debian', 'ubuntu'] - role: vm/network + when: install_distro in ['debian', 'ubuntu'] - role: vm/guest + when: install_distro in ['debian', 'ubuntu'] - import_playbook: "../{{ hostenv }}/{{ hostname }}.yml" diff --git a/dan/sk-2019vm.yml b/dan/sk-2019vm.yml index bb7b7d76..cca2da5f 100644 --- a/dan/sk-2019vm.yml +++ b/dan/sk-2019vm.yml @@ -9,7 +9,7 @@ - role: cryptdisk - role: zfs/base - role: vm/host - - role: installer/debian + - role: installer/debian/base tasks: - name: install post-boot script copy: diff --git a/inventory/group_vars/chaos-at-home/network.yml b/inventory/group_vars/chaos-at-home/network.yml index 73aa2975..28a29081 100644 --- a/inventory/group_vars/chaos-at-home/network.yml +++ b/inventory/group_vars/chaos-at-home/network.yml @@ -43,6 +43,7 @@ network_zones: ch-stats: 10 ch-web: 80 ch-mail: 143 + ch-router-obsd: 253 ch-router: 254 mgmt: diff --git a/inventory/group_vars/kvmhosts/main.yml b/inventory/group_vars/kvmhosts/main.yml index eef2a639..917b41eb 100644 --- a/inventory/group_vars/kvmhosts/main.yml +++ b/inventory/group_vars/kvmhosts/main.yml @@ -1,3 +1,2 @@ --- -preseed_path: /srv/preseed installer_path: /srv/installer diff --git a/inventory/group_vars/openbsd/main.yml b/inventory/group_vars/openbsd/main.yml new file mode 100644 index 00000000..913008d0 --- /dev/null +++ b/inventory/group_vars/openbsd/main.yml @@ -0,0 +1,2 @@ +--- +ansible_python_interpreter: /usr/local/bin/python3.7 diff --git a/inventory/host_vars/ch-router-obsd.yml b/inventory/host_vars/ch-router-obsd.yml new file mode 100644 index 00000000..a88110f3 --- /dev/null +++ b/inventory/host_vars/ch-router-obsd.yml @@ -0,0 +1,28 @@ +--- +vm_host: ch-gnocchi + +install: + host: "{{ vm_host }}" + mem: 512 + numcpu: 1 + disks: + primary: /dev/sda + virtio: + vda: + type: lvm + vg: "{{ hostvars[vm_host].host_name }}" + lv: "{{ inventory_hostname }}" + size: 10g + interfaces: + - bridge: br-svc + name: vio0 + autostart: True + +network: + nameservers: "{{ network_zones.svc.dns }}" + domain: "{{ host_domain }}" + primary: + interface: vio0 + ip: "{{ network_zones.svc.prefix | ipaddr(network_zones.svc.offsets[inventory_hostname]) | ipaddr('address') }}" + mask: "{{ network_zones.svc.prefix | ipaddr('netmask') }}" + gateway: "{{ network_zones.svc.gateway }}" diff --git a/inventory/hosts.ini b/inventory/hosts.ini index e6c3cc97..3892abbe 100644 --- a/inventory/hosts.ini +++ b/inventory/hosts.ini @@ -21,6 +21,7 @@ ch-testvm host_name=testvm ch-mimas2 host_name=mimas ch-gnocchi host_name=gnocchi ch-router host_name=router +ch-router-obsd host_name=router ch-gw-lan host_name=gw-lan ch-jump host_name=jump ansible_port=2342 ansible_host=ch-jump @@ -179,6 +180,10 @@ r3-cccamp19-sw0 chaos-at-home-switches +[openbsd] +ch-router-obsd + + [kvmhosts] ch-atlas ch-gnocchi @@ -193,6 +198,8 @@ ch-keyserver ch-testvm ch-gw-lan ch-jump +ch-router +ch-router-obsd r3-vex2 r3-cccamp19-flora r3-cccamp19-verr diff --git a/preseed/.gitignore b/preseed/.gitignore deleted file mode 100644 index 4f8f2ff1..00000000 --- a/preseed/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*-example.cfg -vm-*.cfg diff --git a/preseed/fetch-example.sh b/preseed/fetch-example.sh deleted file mode 100755 index fa89bdba..00000000 --- a/preseed/fetch-example.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -if [ -z "$1" ] && [ -z "$2" ]; then - echo "Usage: $0 <distro> <codename>" - exit 1 -fi - -distro="$1" -codename="$2" - -case "$distro" in - debian) - wget "https://www.debian.org/releases/$codename/example-preseed.txt" -O "$codename-example.cfg" - ;; - ubuntu) - rel="$codename" - case "$codename" in - xenial) - rel="16.04" - ;; - bionic) - rel="18.04" - ;; - esac - wget "https://help.ubuntu.com/$rel/installation-guide/example-preseed.txt" -O "$codename-example.cfg" - ;; -esac - -exit 0 diff --git a/preseed/hosts/Readme.md b/preseed/hosts/Readme.md deleted file mode 100644 index c6899a8d..00000000 --- a/preseed/hosts/Readme.md +++ /dev/null @@ -1,15 +0,0 @@ -# Preseed files for various hosts - -In order to fully automaticall install you need to start a temporay webserver using this directory as document root: - - python -m SimpleHTTPServer 8000 - -When this is done run the netinst image and intrd with the following boot command line: - - auto=true interface=auto url=http://<ip of your machine>:8000/dione_debian-stretch.cfg netcfg/choose_interface=eno1 netcfg/get_hostname=dione netcfg/get_domain=spreadspace.org - -This example assumes you want to install the host `dione`. -For debugging you may add the following to the kernel command line: - - DEBCONF_DEBUG=5 - diff --git a/preseed/hosts/calypso_debian-stretch.cfg b/preseed/hosts/calypso_debian-stretch.cfg deleted file mode 100644 index bf5f2f61..00000000 --- a/preseed/hosts/calypso_debian-stretch.cfg +++ /dev/null @@ -1,129 +0,0 @@ -######################################################################### -# spreadspace preseed file for Debian stretch based VMs -######################################################################### - -d-i debian-installer/language string en -d-i debian-installer/country string AT -d-i debian-installer/locale string de_AT.UTF-8 -d-i keyboard-configuration/xkb-keymap select de - -# TODO: this does not work :(, probably adding it to the boot options will fix it -d-i hw-detect/load_firmware boolean false - -d-i netcfg/choose_interface select eno1 -d-i netcfg/disable_autoconfig boolean true - -d-i netcfg/get_hostname string calypso -d-i netcfg/get_domain string spreadspace.org -d-i netcfg/wireless_wep string - - -d-i mirror/country string manual -d-i mirror/http/hostname string debian.ffgraz.net -d-i mirror/http/directory string /debian -d-i mirror/http/proxy string - -d-i preseed/early_command string h=$(hostname -s); d=$(hostname -d); sed s/$h/calypso/g -i /etc/hosts /etc/hostname; sed s/$d/spreadspace.org/g -i /etc/hosts; hostname calypso - -d-i passwd/make-user boolean false -d-i passwd/root-password password this-very-very-secure-password-will-be-removed-by-latecommand -d-i passwd/root-password-again password this-very-very-secure-password-will-be-removed-by-latecommand - - -d-i clock-setup/utc boolean true -d-i time/zone string Europe/Vienna -d-i clock-setup/ntp boolean false - -d-i partman-auto/disk string /dev/sda /dev/sdb -d-i partman-auto/method string raid -d-i partman-auto/purge_lvm_from_device boolean true -d-i partman-auto-lvm/new_vg_name string calypso - -d-i partman-lvm/device_remove_lvm boolean true -d-i partman-md/device_remove_md boolean true -d-i partman-md/confirm boolean true -d-i partman-md/confirm_nooverwrite boolean true -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm_nooverwrite boolean true - -d-i partman/choose_label string dos -d-i partman/default_label string dos -d-i partman-auto/choose_recipe select boot-root -d-i partman-auto/expert_recipe string \ - boot-root :: \ - 256 512 256 raid \ - $lvmignore{ } $primary{ } \ - method{ raid } \ - . \ - 1000 10000 -1 raid \ - $lvmignore{ } $primary{ } \ - method{ raid } \ - . \ - 2560 10000 3072 ext4 \ - $defaultignore{ } $lvmok{ } \ - in_vg{ calypso } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ / } \ - . \ - 1024 11000 1280 ext4 \ - $defaultignore{ } $lvmok{ } \ - in_vg{ calypso } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var } \ - . \ - 768 10000 768 ext4 \ - $defaultignore{ } $lvmok{ } \ - in_vg{ calypso } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var/log } \ - options/nodev{ nodev } \ - options/noatime{ noatime } \ - options/noexec{ noexec } \ - . \ - 16 20000 -1 ext4 \ - $defaultignore{ } $lvmok{ } \ - in_vg{ calypso } \ - lv_name{ dummy } \ - . - -d-i partman-auto-raid/recipe string \ - 1 2 0 ext4 /boot \ - /dev/sda1#/dev/sdb1 \ - . \ - 1 2 0 lvm - \ - /dev/sda2#/dev/sdb2 \ - . - -d-i partman-basicfilesystems/no_swap true -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - - -d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string debian.ffgraz.net - -tasksel tasksel/first multiselect -d-i pkgsel/include string openssh-server python -d-i pkgsel/upgrade select safe-upgrade -popularity-contest popularity-contest/participate boolean false - -d-i grub-installer/choose_bootdev string /dev/sda /dev/sdb -d-i grub-installer/bootdev string /dev/sda /dev/sdb -d-i grub-installer/only_debian boolean true -d-i grub-installer/with_other_os boolean false - -d-i nobootloader/confirmation_common boolean true - -d-i finish-install/reboot_in_progress note - - -d-i preseed/late_command string \ - lvremove -f calypso/dummy; \ - in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ - in-target bash -c "sed 's#GRUB_CMDLINE_LINUX_DEFAULT.*#GRUB_CMDLINE_LINUX_DEFAULT=\"quiet nomodeset consoleblank=0\"#' -i /etc/default/grub && update-grub"; \ - in-target bash -c "passwd -d root; passwd -l root; umask 077; mkdir -p /root/.ssh/; echo -e 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtmysXjBidEwJek6hBgaENiyVOwroFi19xRZZw+cYYqi6asDfF6B/h6gYNkJGWo0rD5ZaLdau1O210O5Xu+TfK1e2bZbxuFIj2fguUkat9wN6IQIO2m2Wcf4k/eiTmtAE3dp0l5ThMqfxxE8dj76mOOrUHCfJUIVoATGs4X5TLcGcXroAcZ+DFFoDzjxjFYNmIuUNtXDwXTpPc63SAYmRvW0ZYZlvH1qZ6irLh+GtE1dZ1Q5lQZvp6xUYcjInbpcd5Ko3KbG/In7sNmUCI7iaTwC4DPDTcHFj99Ll1jruAbdaQqe+ClZv55dbQ+92RDF6fsuQBD8FeRz7nYChvCqNPT1KOvcVsDtbW0iJ1PZ05QdE27w23wJj9OE0JWM09P3AH3ttswHaJ+P4s7mSxxK2m6YZcqop3czLlWWoGna0ynd5eV6l/rtvAQUvBOXjKQ5fPQY5d9cF0Z87NBE54HM9a/IKZ2toU2MuYNUpI/DUoAA9ILS4bJm3AUz8wbaC5EiuIhbM6I/u0NANamaQKRrolGNP4ETaQvhABs+S3/NSSBy4DMjtwax2BxyenF6i89vyHPNY+LZzBOn842yUlEGn6Z11MxiE5fhIfMPUclSYi5bQJDf1fvAyAo59/AX8sPqRK+/OCLIgLwdtW6D4OZGXjqrBJe2j/5uZSJEsl6ROyKw== equinox@spreadspace.org' > /root/.ssh/authorized_keys" diff --git a/preseed/hosts/dione_debian-stretch.cfg b/preseed/hosts/dione_debian-stretch.cfg deleted file mode 100644 index 8f989ff6..00000000 --- a/preseed/hosts/dione_debian-stretch.cfg +++ /dev/null @@ -1,114 +0,0 @@ -######################################################################### -# spreadspace preseed file for Debian stretch based VMs -######################################################################### - -d-i debian-installer/language string en -d-i debian-installer/country string AT -d-i debian-installer/locale string de_AT.UTF-8 -d-i keyboard-configuration/xkb-keymap select de - - -d-i netcfg/choose_interface select eno1 -d-i netcfg/disable_autoconfig boolean true - -d-i netcfg/get_hostname string dione -d-i netcfg/get_domain string spreadspace.org -d-i netcfg/wireless_wep string - - -d-i mirror/country string manual -d-i mirror/http/hostname string debian.ffgraz.net -d-i mirror/http/directory string /debian -d-i mirror/http/proxy string - -d-i preseed/early_command string h=$(hostname -s); d=$(hostname -d); sed s/$h/dione/g -i /etc/hosts /etc/hostname; sed s/$d/spreadspace.org/g -i /etc/hosts; hostname dione - -d-i passwd/make-user boolean false -d-i passwd/root-password password this-very-very-secure-password-will-be-removed-by-latecommand -d-i passwd/root-password-again password this-very-very-secure-password-will-be-removed-by-latecommand - - -d-i clock-setup/utc boolean true -d-i time/zone string Europe/Vienna -d-i clock-setup/ntp boolean false - -d-i partman-efi/non_efi_system boolean true -d-i partman-auto/disk string /dev/nvme0n1 -d-i partman-auto/method string lvm -d-i partman-auto/purge_lvm_from_device boolean true -d-i partman-auto-lvm/new_vg_name string dione - -d-i partman-lvm/device_remove_lvm boolean true -d-i partman-md/device_remove_md boolean true -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm_nooverwrite boolean true - -d-i partman/choose_label string gpt -d-i partman/default_label string gpt -d-i partman-auto/choose_recipe select boot-root -d-i partman-auto/expert_recipe string \ - boot-root :: \ - 100 100 128 fat16 \ - $defaultignore{ } $primary{ } \ - $bootable{ } method{ efi } format{ } \ - . \ - 1000 10000 -1 ext4 \ - $defaultignore{ } $primary{ } \ - method{ lvm } vg_name{ dione } \ - . \ - 2560 10000 3072 ext4 \ - $lvmok{ } in_vg{ dione } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ / } \ - . \ - 1024 11000 1280 ext4 \ - $lvmok{ } in_vg{ dione } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var } \ - . \ - 768 10000 768 ext4 \ - $lvmok{ } in_vg{ dione } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var/log } \ - options/nodev{ nodev } \ - options/noatime{ noatime } \ - options/noexec{ noexec } \ - . \ - 16 20000 -1 ext4 \ - $lvmok{ } in_vg{ dione } \ - method( keep } lv_name{ dummy } \ - . - -d-i partman-auto-lvm/no_boot boolean true -d-i partman-basicfilesystems/no_swap true -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - - -d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string debian.ffgraz.net - -tasksel tasksel/first multiselect -d-i pkgsel/include string openssh-server python -d-i pkgsel/upgrade select safe-upgrade -popularity-contest popularity-contest/participate boolean false - -d-i grub-installer/choose_bootdev string /dev/nvme0n1 -d-i grub-installer/only_debian boolean true -d-i grub-installer/with_other_os boolean false - -d-i nobootloader/confirmation_common boolean true - -d-i finish-install/reboot_in_progress note - - -d-i preseed/late_command string \ - lvremove -f dione/dummy; \ - in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ - in-target bash -c "sed 's#GRUB_CMDLINE_LINUX_DEFAULT.*#GRUB_CMDLINE_LINUX_DEFAULT=\"quiet nomodeset consoleblank=0\"#' -i /etc/default/grub && update-grub"; \ - in-target bash -c "passwd -d root; passwd -l root; umask 077; mkdir -p /root/.ssh/; echo -e 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtmysXjBidEwJek6hBgaENiyVOwroFi19xRZZw+cYYqi6asDfF6B/h6gYNkJGWo0rD5ZaLdau1O210O5Xu+TfK1e2bZbxuFIj2fguUkat9wN6IQIO2m2Wcf4k/eiTmtAE3dp0l5ThMqfxxE8dj76mOOrUHCfJUIVoATGs4X5TLcGcXroAcZ+DFFoDzjxjFYNmIuUNtXDwXTpPc63SAYmRvW0ZYZlvH1qZ6irLh+GtE1dZ1Q5lQZvp6xUYcjInbpcd5Ko3KbG/In7sNmUCI7iaTwC4DPDTcHFj99Ll1jruAbdaQqe+ClZv55dbQ+92RDF6fsuQBD8FeRz7nYChvCqNPT1KOvcVsDtbW0iJ1PZ05QdE27w23wJj9OE0JWM09P3AH3ttswHaJ+P4s7mSxxK2m6YZcqop3czLlWWoGna0ynd5eV6l/rtvAQUvBOXjKQ5fPQY5d9cF0Z87NBE54HM9a/IKZ2toU2MuYNUpI/DUoAA9ILS4bJm3AUz8wbaC5EiuIhbM6I/u0NANamaQKRrolGNP4ETaQvhABs+S3/NSSBy4DMjtwax2BxyenF6i89vyHPNY+LZzBOn842yUlEGn6Z11MxiE5fhIfMPUclSYi5bQJDf1fvAyAo59/AX8sPqRK+/OCLIgLwdtW6D4OZGXjqrBJe2j/5uZSJEsl6ROyKw== equinox@spreadspace.org' > /root/.ssh/authorized_keys" diff --git a/preseed/hosts/helene_debian-stretch.cfg b/preseed/hosts/helene_debian-stretch.cfg deleted file mode 100644 index b89e7326..00000000 --- a/preseed/hosts/helene_debian-stretch.cfg +++ /dev/null @@ -1,114 +0,0 @@ -######################################################################### -# spreadspace preseed file for Debian stretch based VMs -######################################################################### - -d-i debian-installer/language string en -d-i debian-installer/country string AT -d-i debian-installer/locale string de_AT.UTF-8 -d-i keyboard-configuration/xkb-keymap select de - - -d-i netcfg/choose_interface select eno1 -d-i netcfg/disable_autoconfig boolean true - -d-i netcfg/get_hostname string helene -d-i netcfg/get_domain string spreadspace.org -d-i netcfg/wireless_wep string - - -d-i mirror/country string manual -d-i mirror/http/hostname string debian.ffgraz.net -d-i mirror/http/directory string /debian -d-i mirror/http/proxy string - -d-i preseed/early_command string h=$(hostname -s); d=$(hostname -d); sed s/$h/helene/g -i /etc/hosts /etc/hostname; sed s/$d/spreadspace.org/g -i /etc/hosts; hostname helene - -d-i passwd/make-user boolean false -d-i passwd/root-password password this-very-very-secure-password-will-be-removed-by-latecommand -d-i passwd/root-password-again password this-very-very-secure-password-will-be-removed-by-latecommand - - -d-i clock-setup/utc boolean true -d-i time/zone string Europe/Vienna -d-i clock-setup/ntp boolean false - -d-i partman-efi/non_efi_system boolean true -d-i partman-auto/disk string /dev/nvme0n1 -d-i partman-auto/method string lvm -d-i partman-auto/purge_lvm_from_device boolean true -d-i partman-auto-lvm/new_vg_name string helene - -d-i partman-lvm/device_remove_lvm boolean true -d-i partman-md/device_remove_md boolean true -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm_nooverwrite boolean true - -d-i partman/choose_label string gpt -d-i partman/default_label string gpt -d-i partman-auto/choose_recipe select boot-root -d-i partman-auto/expert_recipe string \ - boot-root :: \ - 100 100 128 fat16 \ - $defaultignore{ } $primary{ } \ - $bootable{ } method{ efi } format{ } \ - . \ - 1000 10000 -1 ext4 \ - $defaultignore{ } $primary{ } \ - method{ lvm } vg_name{ helene } \ - . \ - 2560 10000 3072 ext4 \ - $lvmok{ } in_vg{ helene } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ / } \ - . \ - 1024 11000 1280 ext4 \ - $lvmok{ } in_vg{ helene } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var } \ - . \ - 768 10000 768 ext4 \ - $lvmok{ } in_vg{ helene } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var/log } \ - options/nodev{ nodev } \ - options/noatime{ noatime } \ - options/noexec{ noexec } \ - . \ - 16 20000 -1 ext4 \ - $lvmok{ } in_vg{ helene } \ - method( keep } lv_name{ dummy } \ - . - -d-i partman-auto-lvm/no_boot boolean true -d-i partman-basicfilesystems/no_swap true -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - - -d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string debian.ffgraz.net - -tasksel tasksel/first multiselect -d-i pkgsel/include string openssh-server python -d-i pkgsel/upgrade select safe-upgrade -popularity-contest popularity-contest/participate boolean false - -d-i grub-installer/choose_bootdev string /dev/nvme0n1 -d-i grub-installer/only_debian boolean true -d-i grub-installer/with_other_os boolean false - -d-i nobootloader/confirmation_common boolean true - -d-i finish-install/reboot_in_progress note - - -d-i preseed/late_command string \ - lvremove -f helene/dummy; \ - in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ - in-target bash -c "sed 's#GRUB_CMDLINE_LINUX_DEFAULT.*#GRUB_CMDLINE_LINUX_DEFAULT=\"quiet nomodeset consoleblank=0\"#' -i /etc/default/grub && update-grub"; \ - in-target bash -c "passwd -d root; passwd -l root; umask 077; mkdir -p /root/.ssh/; echo -e 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtmysXjBidEwJek6hBgaENiyVOwroFi19xRZZw+cYYqi6asDfF6B/h6gYNkJGWo0rD5ZaLdau1O210O5Xu+TfK1e2bZbxuFIj2fguUkat9wN6IQIO2m2Wcf4k/eiTmtAE3dp0l5ThMqfxxE8dj76mOOrUHCfJUIVoATGs4X5TLcGcXroAcZ+DFFoDzjxjFYNmIuUNtXDwXTpPc63SAYmRvW0ZYZlvH1qZ6irLh+GtE1dZ1Q5lQZvp6xUYcjInbpcd5Ko3KbG/In7sNmUCI7iaTwC4DPDTcHFj99Ll1jruAbdaQqe+ClZv55dbQ+92RDF6fsuQBD8FeRz7nYChvCqNPT1KOvcVsDtbW0iJ1PZ05QdE27w23wJj9OE0JWM09P3AH3ttswHaJ+P4s7mSxxK2m6YZcqop3czLlWWoGna0ynd5eV6l/rtvAQUvBOXjKQ5fPQY5d9cF0Z87NBE54HM9a/IKZ2toU2MuYNUpI/DUoAA9ILS4bJm3AUz8wbaC5EiuIhbM6I/u0NANamaQKRrolGNP4ETaQvhABs+S3/NSSBy4DMjtwax2BxyenF6i89vyHPNY+LZzBOn842yUlEGn6Z11MxiE5fhIfMPUclSYi5bQJDf1fvAyAo59/AX8sPqRK+/OCLIgLwdtW6D4OZGXjqrBJe2j/5uZSJEsl6ROyKw== equinox@spreadspace.org' > /root/.ssh/authorized_keys" diff --git a/preseed/hosts/telesto_debian-stretch.cfg b/preseed/hosts/telesto_debian-stretch.cfg deleted file mode 100644 index 5bbd382b..00000000 --- a/preseed/hosts/telesto_debian-stretch.cfg +++ /dev/null @@ -1,126 +0,0 @@ -######################################################################### -# spreadspace preseed file for Debian stretch based VMs -######################################################################### - -d-i debian-installer/language string en -d-i debian-installer/country string AT -d-i debian-installer/locale string de_AT.UTF-8 -d-i keyboard-configuration/xkb-keymap select de - -d-i netcfg/choose_interface select eno1 -d-i netcfg/disable_autoconfig boolean true - -d-i netcfg/get_hostname string telesto -d-i netcfg/get_domain string spreadspace.org -d-i netcfg/wireless_wep string - - -d-i mirror/country string manual -d-i mirror/http/hostname string debian.ffgraz.net -d-i mirror/http/directory string /debian -d-i mirror/http/proxy string - -d-i preseed/early_command string h=$(hostname -s); d=$(hostname -d); sed s/$h/telesto/g -i /etc/hosts /etc/hostname; sed s/$d/spreadspace.org/g -i /etc/hosts; hostname telesto - -d-i passwd/make-user boolean false -d-i passwd/root-password password this-very-very-secure-password-will-be-removed-by-latecommand -d-i passwd/root-password-again password this-very-very-secure-password-will-be-removed-by-latecommand - - -d-i clock-setup/utc boolean true -d-i time/zone string Europe/Vienna -d-i clock-setup/ntp boolean false - -d-i partman-auto/disk string /dev/sda /dev/sdb -d-i partman-auto/method string raid -d-i partman-auto/purge_lvm_from_device boolean true -d-i partman-auto-lvm/new_vg_name string telesto - -d-i partman-lvm/device_remove_lvm boolean true -d-i partman-md/device_remove_md boolean true -d-i partman-md/confirm boolean true -d-i partman-md/confirm_nooverwrite boolean true -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm_nooverwrite boolean true - -d-i partman/choose_label string dos -d-i partman/default_label string dos -d-i partman-auto/choose_recipe select boot-root -d-i partman-auto/expert_recipe string \ - boot-root :: \ - 256 512 256 raid \ - $lvmignore{ } $primary{ } \ - method{ raid } \ - . \ - 1000 10000 -1 raid \ - $lvmignore{ } $primary{ } \ - method{ raid } \ - . \ - 2560 10000 3072 ext4 \ - $defaultignore{ } $lvmok{ } \ - in_vg{ telesto } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ / } \ - . \ - 1024 11000 1280 ext4 \ - $defaultignore{ } $lvmok{ } \ - in_vg{ telesto } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var } \ - . \ - 768 10000 768 ext4 \ - $defaultignore{ } $lvmok{ } \ - in_vg{ telesto } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var/log } \ - options/nodev{ nodev } \ - options/noatime{ noatime } \ - options/noexec{ noexec } \ - . \ - 16 20000 -1 ext4 \ - $defaultignore{ } $lvmok{ } \ - in_vg{ telesto } \ - lv_name{ dummy } \ - . - -d-i partman-auto-raid/recipe string \ - 1 2 0 ext4 /boot \ - /dev/sda1#/dev/sdb1 \ - . \ - 1 2 0 lvm - \ - /dev/sda2#/dev/sdb2 \ - . - -d-i partman-basicfilesystems/no_swap true -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - - -d-i base-installer/install-recommends boolean false -d-i apt-setup/security_host string debian.ffgraz.net - -tasksel tasksel/first multiselect -d-i pkgsel/include string openssh-server python -d-i pkgsel/upgrade select safe-upgrade -popularity-contest popularity-contest/participate boolean false - -d-i grub-installer/choose_bootdev string /dev/sda /dev/sdb -d-i grub-installer/bootdev string /dev/sda /dev/sdb -d-i grub-installer/only_debian boolean true -d-i grub-installer/with_other_os boolean false - -d-i nobootloader/confirmation_common boolean true - -d-i finish-install/reboot_in_progress note - - -d-i preseed/late_command string \ - lvremove -f telesto/dummy; \ - in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ - in-target bash -c "sed 's#GRUB_CMDLINE_LINUX_DEFAULT.*#GRUB_CMDLINE_LINUX_DEFAULT=\"quiet nomodeset consoleblank=0\"#' -i /etc/default/grub && update-grub"; \ - in-target bash -c "passwd -d root; passwd -l root; umask 077; mkdir -p /root/.ssh/; echo -e 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtmysXjBidEwJek6hBgaENiyVOwroFi19xRZZw+cYYqi6asDfF6B/h6gYNkJGWo0rD5ZaLdau1O210O5Xu+TfK1e2bZbxuFIj2fguUkat9wN6IQIO2m2Wcf4k/eiTmtAE3dp0l5ThMqfxxE8dj76mOOrUHCfJUIVoATGs4X5TLcGcXroAcZ+DFFoDzjxjFYNmIuUNtXDwXTpPc63SAYmRvW0ZYZlvH1qZ6irLh+GtE1dZ1Q5lQZvp6xUYcjInbpcd5Ko3KbG/In7sNmUCI7iaTwC4DPDTcHFj99Ll1jruAbdaQqe+ClZv55dbQ+92RDF6fsuQBD8FeRz7nYChvCqNPT1KOvcVsDtbW0iJ1PZ05QdE27w23wJj9OE0JWM09P3AH3ttswHaJ+P4s7mSxxK2m6YZcqop3czLlWWoGna0ynd5eV6l/rtvAQUvBOXjKQ5fPQY5d9cF0Z87NBE54HM9a/IKZ2toU2MuYNUpI/DUoAA9ILS4bJm3AUz8wbaC5EiuIhbM6I/u0NANamaQKRrolGNP4ETaQvhABs+S3/NSSBy4DMjtwax2BxyenF6i89vyHPNY+LZzBOn842yUlEGn6Z11MxiE5fhIfMPUclSYi5bQJDf1fvAyAo59/AX8sPqRK+/OCLIgLwdtW6D4OZGXjqrBJe2j/5uZSJEsl6ROyKw== equinox@spreadspace.org' > /root/.ssh/authorized_keys" diff --git a/roles/base/tasks/Debian.yml b/roles/base/tasks/Debian.yml new file mode 100644 index 00000000..25195ad2 --- /dev/null +++ b/roles/base/tasks/Debian.yml @@ -0,0 +1,124 @@ +--- +- name: load distrubtion specific variables + include_vars: "{{ item }}" + with_first_found: + - files: + - "{{ ansible_distribution_release }}.yml" + - "{{ ansible_distribution }}.yml" + skip: true + +- name: disable recommends and suggests + copy: + src: 02no-recommends + dest: /etc/apt/apt.conf.d/ + +- name: install base system tools + apt: + name: + - htop + - dstat + - lsof + - gawk + - psmisc + - less + - debian-goodies + - screen + - mtr-tiny + - tcpdump + - iptraf-ng + - unp + - dbus + - libpam-systemd + - aptitude + - ca-certificates + - file + - man-db + - manpages + - nano + state: present + +- name: install extra packages + apt: + name: "{{ base_packages_extra_host | union(base_packages_extra_group) }}" + state: present + +- name: install rngd + when: base_entropy_generator == 'rngd' + block: + - name: install rngd + apt: + name: "{{ base_rngd_package_name }}" + state: present + + - name: make sure haveged is removed/purged + apt: + name: haveged + state: absent + purge: yes + + +- name: install haveged + when: base_entropy_generator == 'haveged' + block: + - name: install haveged + apt: + name: haveged + state: present + + - name: make sure rngd is removed/purged + apt: + name: "{{ base_rngd_package_name }}" + state: absent + purge: yes + + +- name: Ensure /root is not world accessible + file: + path: /root + mode: 0700 + owner: root + group: root + state: directory + +- name: disable net/fs/misc kernel modules + loop: "{{ modules_blacklist.net | union(modules_blacklist.fs) | union(modules_blacklist.misc) }}" + lineinfile: + dest: /etc/modprobe.d/disablemod.conf + line: "install {{ item }} /bin/true" + create: yes + owner: root + group: root + mode: 0644 + +- name: Change various sysctl-settings, look at the sysctl-vars file for documentation + loop: "{{ sysctl_config | combine(sysctl_config_user) | dict2items }}" + loop_control: + label: "{{ item.key }} = {{ item.value }}" + sysctl: + name: "{{ item.key }}" + value: "{{ item.value }}" + sysctl_set: yes + state: present + reload: yes + ignoreerrors: yes + +- name: set kernel command line options + lineinfile: + path: /etc/default/grub + regexp: '^#?GRUB_CMDLINE_LINUX=' + line: 'GRUB_CMDLINE_LINUX="{{ install.kernel_cmdline | join(" ") }}"' + when: install is defined and install.kernel_cmdline is defined + notify: update grub + +- name: disable TSO (intel nic stability fix) + when: base_intel_nic_stability_fix + copy: + content: | + [Match] + MACAddress={{ ansible_default_ipv4.macaddress }} + + [Link] + TCPSegmentationOffload=false + GenericSegmentationOffload=false + GenericReceiveOffload=false + dest: /etc/systemd/network/00-disable-offloading.link diff --git a/roles/base/tasks/OpenBSD.yml b/roles/base/tasks/OpenBSD.yml new file mode 100644 index 00000000..4b64105c --- /dev/null +++ b/roles/base/tasks/OpenBSD.yml @@ -0,0 +1,14 @@ +--- +- name: install base system tools + openbsd_pkg: + name: + - htop + - screen-- + - mtr-- + - nano + state: present + +- name: install extra packages + openbsd_pkg: + name: "{{ base_packages_extra_host | union(base_packages_extra_group) }}" + state: present diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index 3f1d9bee..5484a3a6 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -1,72 +1,15 @@ --- -- name: load distrubtion specific variables - include_vars: "{{ item }}" - with_first_found: - - files: - - "{{ ansible_distribution_release }}.yml" - - "{{ ansible_distribution }}.yml" - skip: true - -- name: disable recommends and suggests - copy: - src: 02no-recommends - dest: /etc/apt/apt.conf.d/ - -- name: install base system tools - apt: - name: - - htop - - dstat - - lsof - - gawk - - psmisc - - less - - debian-goodies - - screen - - mtr-tiny - - tcpdump - - iptraf-ng - - unp - - dbus - - libpam-systemd - - aptitude - - ca-certificates - - file - - man-db - - manpages - - nano - state: present - - -- name: install rngd - when: base_entropy_generator == 'rngd' - block: - - name: install rngd - apt: - name: "{{ base_rngd_package_name }}" - state: present - - - name: make sure haveged is removed/purged - apt: - name: haveged - state: absent - purge: yes - - -- name: install haveged - when: base_entropy_generator == 'haveged' - block: - - name: install haveged - apt: - name: haveged - state: present - - - name: make sure rngd is removed/purged - apt: - name: "{{ base_rngd_package_name }}" - state: absent - purge: yes - +- name: load os/distrubtion/version specific tasks + vars: + params: + files: + - "{{ ansible_distribution_release }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + loop: "{{ q('first_found', params) }}" + loop_control: + loop_var: tasks_file + include_tasks: "{{ tasks_file }}" - name: Remove startup message from screen lineinfile: @@ -93,59 +36,3 @@ copy: src: "{{ global_files_dir }}/common/htoprc" dest: "{{ item }}/.config/htop/" - -- name: Ensure /root is not world accessible - file: - path: /root - mode: 0700 - owner: root - group: root - state: directory - -- name: disable net/fs/misc kernel modules - loop: "{{ modules_blacklist.net | union(modules_blacklist.fs) | union(modules_blacklist.misc) }}" - lineinfile: - dest: /etc/modprobe.d/disablemod.conf - line: "install {{ item }} /bin/true" - create: yes - owner: root - group: root - mode: 0644 - -- name: Change various sysctl-settings, look at the sysctl-vars file for documentation - loop: "{{ sysctl_config | combine(sysctl_config_user) | dict2items }}" - loop_control: - label: "{{ item.key }} = {{ item.value }}" - sysctl: - name: "{{ item.key }}" - value: "{{ item.value }}" - sysctl_set: yes - state: present - reload: yes - ignoreerrors: yes - -- name: install extra packages - apt: - name: "{{ base_packages_extra_host | union(base_packages_extra_group) }}" - state: present - -- name: set kernel command line options - lineinfile: - path: /etc/default/grub - regexp: '^#?GRUB_CMDLINE_LINUX=' - line: 'GRUB_CMDLINE_LINUX="{{ install.kernel_cmdline | join(" ") }}"' - when: install is defined and install.kernel_cmdline is defined - notify: update grub - -- name: disable TSO (intel nic stability fix) - when: base_intel_nic_stability_fix - copy: - content: | - [Match] - MACAddress={{ ansible_default_ipv4.macaddress }} - - [Link] - TCPSegmentationOffload=false - GenericSegmentationOffload=false - GenericReceiveOffload=false - dest: /etc/systemd/network/00-disable-offloading.link diff --git a/roles/installer/debian/defaults/main.yml b/roles/installer/debian/base/defaults/main.yml index 8962e9ad..8962e9ad 100644 --- a/roles/installer/debian/defaults/main.yml +++ b/roles/installer/debian/base/defaults/main.yml diff --git a/roles/installer/debian/tasks/main.yml b/roles/installer/debian/base/tasks/main.yml index 92fac536..92fac536 100644 --- a/roles/installer/debian/tasks/main.yml +++ b/roles/installer/debian/base/tasks/main.yml diff --git a/roles/preseed/defaults/main.yml b/roles/installer/debian/preseed/defaults/main.yml index c5400493..18cfd952 100644 --- a/roles/preseed/defaults/main.yml +++ b/roles/installer/debian/preseed/defaults/main.yml @@ -1,4 +1,5 @@ --- -#preseed_force_net_ifnames_policy: path +#preseed_tmpdir: +#preseed_force_net_ifnames_policy: path preseed_no_netplan: no diff --git a/roles/preseed/tasks/main.yml b/roles/installer/debian/preseed/tasks/main.yml index b1b5d275..b1b5d275 100644 --- a/roles/preseed/tasks/main.yml +++ b/roles/installer/debian/preseed/tasks/main.yml diff --git a/roles/preseed/templates/preseed_debian-buster.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_debian-buster.cfg.j2 index 9952fa0a..9952fa0a 100644 --- a/roles/preseed/templates/preseed_debian-buster.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_debian-buster.cfg.j2 diff --git a/roles/preseed/templates/preseed_debian-jessie.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_debian-jessie.cfg.j2 index 4519d910..4519d910 100644 --- a/roles/preseed/templates/preseed_debian-jessie.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_debian-jessie.cfg.j2 diff --git a/roles/preseed/templates/preseed_debian-stretch.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_debian-stretch.cfg.j2 index 8969fa7c..8969fa7c 100644 --- a/roles/preseed/templates/preseed_debian-stretch.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_debian-stretch.cfg.j2 diff --git a/roles/preseed/templates/preseed_ubuntu-bionic.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_ubuntu-bionic.cfg.j2 index a2fffd11..a2fffd11 100644 --- a/roles/preseed/templates/preseed_ubuntu-bionic.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_ubuntu-bionic.cfg.j2 diff --git a/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_ubuntu-xenial.cfg.j2 index 0b3d3698..0b3d3698 100644 --- a/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_ubuntu-xenial.cfg.j2 diff --git a/roles/preseed/templates/preseed_xubuntu-cosmic-desktop-with-raid.cfg.j2 b/roles/installer/debian/preseed/templates/preseed_xubuntu-cosmic-desktop-with-raid.cfg.j2 index 22f47ce7..22f47ce7 100644 --- a/roles/preseed/templates/preseed_xubuntu-cosmic-desktop-with-raid.cfg.j2 +++ b/roles/installer/debian/preseed/templates/preseed_xubuntu-cosmic-desktop-with-raid.cfg.j2 diff --git a/roles/installer/openbsd/autoinstall/defaults/main.yml b/roles/installer/openbsd/autoinstall/defaults/main.yml new file mode 100644 index 00000000..cdea194e --- /dev/null +++ b/roles/installer/openbsd/autoinstall/defaults/main.yml @@ -0,0 +1,19 @@ +--- +# obsd_autoinstall_tmpdir: + +obsd_autoinstall_arch: "{{ hostvars[hostname].install_cooked.arch | default('amd64') }}" +obsd_autoinstall_version: "{{ install_codename }}" +obsd_autoinstall_version_short: "{{ obsd_autoinstall_version | replace('.', '') }}" + +# obsd_autoinstall_serial_device: com0 +# obsd_autoinstall_serial_baudrate: 115200 + +obsd_autoinstall_file_sets: + - base + - man + #- comp + #- game + #- xbase + #- xfont + #- xserv + #- xshare diff --git a/roles/installer/openbsd/autoinstall/tasks/main.yml b/roles/installer/openbsd/autoinstall/tasks/main.yml new file mode 100644 index 00000000..cb9975de --- /dev/null +++ b/roles/installer/openbsd/autoinstall/tasks/main.yml @@ -0,0 +1,63 @@ +--- +- name: create temporary directories + loop: + - files/etc + - files/sets + - site/ + file: + path: "{{ obsd_autoinstall_tmpdir }}/{{ item }}" + state: directory + +- name: extract installer files from iso + iso_extract: + image: "{{ installer_path }}/openbsd-{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/install.iso" + dest: "{{ obsd_autoinstall_tmpdir }}/files" + files: + - "{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/cdbr" + - "{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/cdboot" + - "{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/bsd.rd" + +- name: generate bootloader and installer configuration + loop: + - auto_install.conf + - boot.conf + template: + src: "{{ item }}.j2" + dest: "{{ obsd_autoinstall_tmpdir }}/files/etc/{{ item }}" + +- name: generate random seed + shell: "head -c512 < /dev/random > {{ obsd_autoinstall_tmpdir }}/files/etc/random.seed" + +- name: extract file-sets from iso + vars: + set_names: + - bsd + - bsd.rd + - "INSTALL.{{ obsd_autoinstall_arch }}" + - "{{ obsd_autoinstall_file_sets | product([obsd_autoinstall_version_short+'.tgz']) | map('join') | list }}" + iso_extract: + image: "{{ installer_path }}/openbsd-{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/install.iso" + dest: "{{ obsd_autoinstall_tmpdir }}/files/sets" + files: "{{ [obsd_autoinstall_version+'/'+obsd_autoinstall_arch+'/'] | product(set_names | flatten) | map('join') | list }}" + +- name: generate install.site script + template: + src: install.site.j2 + dest: "{{ obsd_autoinstall_tmpdir }}/site/install.site" + mode: 0755 + +- name: generate site tarball + archive: + path: "{{ obsd_autoinstall_tmpdir }}/site/" + dest: "{{ obsd_autoinstall_tmpdir }}/files/sets/site{{ obsd_autoinstall_version_short }}.tgz" + +- name: generate host specific installer image + command: 'genisoimage -RTLldDN -o "install.iso" -no-emul-boot -b "cdbr" -c "boot.catalog" files/' + args: + chdir: "{{ obsd_autoinstall_tmpdir }}/" + +- name: set additional installer info + set_fact: + installer_manual_steps_msg: | + * at the installer prompt select: (S)hell + * # mount_cd9660 /dev/cd0c /mnt && cp /mnt/etc/auto_install.conf / && autoinstall diff --git a/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2 b/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2 new file mode 100644 index 00000000..18e85a80 --- /dev/null +++ b/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2 @@ -0,0 +1,32 @@ +System hostname = {{ hostvars[hostname].host_name }} + +Which network interface do you wish to configure = {{ install_interface | default(hostvars[hostname].network_cooked.primary.interface) }} +{% if 'install_dhcp' in hostvars[hostname] and hostvars[hostname].install_dhcp %} +IPv4 address = dhcp +{% else %} +IPv4 address = {{ hostvars[hostname].network_cooked.primary.ip }} +Netmask = {{ hostvars[hostname].network_cooked.primary.mask }} +Default IPv4 route = {{ hostvars[hostname].network_cooked.primary.gateway }} +{% endif %} +DNS domain name = {{ hostvars[hostname].network_cooked.domain }} +DNS nameservers = {{ hostvars[hostname].network_cooked.nameservers | join(' ') }} + +{% if obsd_autoinstall_serial_device is defined %} +Change the default console to {{ obsd_autoinstall_serial_device }} = yes +Which speed should {{ obsd_autoinstall_serial_device }} use = {{ obsd_autoinstall_tty_serial | default(115200) }} +{% endif %} + +{# we will install only one key for now, install.site will install the rest #} +Public ssh key for root account = {{ ssh_keys_root[0] }} +Password for root = this-very-very-secure-password-will-be-overwritten-by-install.site +Setup a user = no +Start sshd(8) by default = yes +Allow root ssh login = prohibit-password + +What timezone are you in = Europe/Vienna + +Location of sets = cd0 +Pathname to the sets = sets/ +Set name(s) = all +{# iso-images don't contain the SHA256.sig file but are verified when downloading the iso-file #} +Directory does not contain SHA256.sig. Continue without verification = yes diff --git a/roles/installer/openbsd/autoinstall/templates/boot.conf.j2 b/roles/installer/openbsd/autoinstall/templates/boot.conf.j2 new file mode 100644 index 00000000..d6cdcfeb --- /dev/null +++ b/roles/installer/openbsd/autoinstall/templates/boot.conf.j2 @@ -0,0 +1,5 @@ +{% if obsd_autoinstall_serial_device is defined %} +stty {{ obsd_autoinstall_serial_device }} {{ obsd_autoinstall_tty_serial | default(115200) }} +set tty {{ obsd_autoinstall_serial_device }} +{% endif %} +set image /bsd.rd diff --git a/roles/installer/openbsd/autoinstall/templates/install.site.j2 b/roles/installer/openbsd/autoinstall/templates/install.site.j2 new file mode 100644 index 00000000..82928daa --- /dev/null +++ b/roles/installer/openbsd/autoinstall/templates/install.site.j2 @@ -0,0 +1,26 @@ +#!/bin/sh + +echo "Generating random root pasword" +usermod -p "$(openssl rand -base64 24 | encrypt)" root + +echo "Installing SSH keys for root" +cat <<EOF > /root/.ssh/authorized_keys +{{ ssh_keys_root | join('\n') }} +EOF + +{% if hostvars[hostname].ansible_port is defined %} +echo "Setting SSH port to {{ hostvars[hostname].ansible_port }}" +sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config +{% endif %} + +echo "Installing python" +pkg_add -Im python%3.7 + +echo "Disable sndiod service on first boot" +cat <<EOF >> /etc/rc.firsttime + +rcctl disable sndiod +rcctl stop sndiod +EOF + +rm /install.site diff --git a/roles/installer/openbsd/defaults/main.yml b/roles/installer/openbsd/base/defaults/main.yml index 004b8ecc..6650e064 100644 --- a/roles/installer/openbsd/defaults/main.yml +++ b/roles/installer/openbsd/base/defaults/main.yml @@ -5,4 +5,4 @@ openbsd_versions: - i386 openbsd_installer_force_download: no -openbsd_installer_url: "https://cdn.openbsd.org/pub/OpenBSD/" +openbsd_installer_url: "https://ftp2.eu.openbsd.org/pub/OpenBSD/" diff --git a/roles/installer/openbsd/tasks/main.yml b/roles/installer/openbsd/base/tasks/main.yml index e7196258..0d5053d5 100644 --- a/roles/installer/openbsd/tasks/main.yml +++ b/roles/installer/openbsd/base/tasks/main.yml @@ -15,3 +15,10 @@ dest: "{{ installer_path }}/openbsd-{{ item.0.version }}/{{ item.1 }}/install.iso" mode: 0644 force: "{{ openbsd_installer_force_download }}" + +# TODO: verify the image using openbsd-signify + +- name: install genisoimage + apt: + name: genisoimage + state: present diff --git a/roles/sshd/handlers/main.yml b/roles/sshd/handlers/main.yml index 822887e3..ea76595a 100644 --- a/roles/sshd/handlers/main.yml +++ b/roles/sshd/handlers/main.yml @@ -1,5 +1,5 @@ --- - name: restart ssh service: - name: ssh + name: "{{ sshd_service_name }}" state: restarted diff --git a/roles/sshd/tasks/main.yml b/roles/sshd/tasks/main.yml index 2977d20b..d73d778b 100644 --- a/roles/sshd/tasks/main.yml +++ b/roles/sshd/tasks/main.yml @@ -1,8 +1,11 @@ --- -- name: install ssh-server - apt: - name: openssh-server - state: present +- name: load os/distrubtion/version specific variables + include_vars: "{{ item }}" + with_first_found: + - files: + - "{{ ansible_distribution_release }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" - name: hardening ssh-server config vars: @@ -37,6 +40,7 @@ exclusive: yes - name: delete root password + when: sshd_disabled_password is defined user: name: root - password: "!" + password: "{{ sshd_disabled_password }}" diff --git a/roles/sshd/vars/Debian.yml b/roles/sshd/vars/Debian.yml new file mode 100644 index 00000000..abbccabc --- /dev/null +++ b/roles/sshd/vars/Debian.yml @@ -0,0 +1,3 @@ +--- +sshd_service_name: ssh +sshd_disabled_password: '!' diff --git a/roles/sshd/vars/OpenBSD.yml b/roles/sshd/vars/OpenBSD.yml new file mode 100644 index 00000000..abdaf180 --- /dev/null +++ b/roles/sshd/vars/OpenBSD.yml @@ -0,0 +1,2 @@ +--- +sshd_service_name: sshd diff --git a/roles/usb-install/meta/main.yml b/roles/usb-install/meta/main.yml index 0fc96588..9db4a441 100644 --- a/roles/usb-install/meta/main.yml +++ b/roles/usb-install/meta/main.yml @@ -1,5 +1,5 @@ dependencies: - - role: installer/debian + - role: installer/debian/base distros: - distro: "{{ install_distro }}" codename: "{{ install_codename }}" diff --git a/roles/usb-install/tasks/main.yml b/roles/usb-install/tasks/main.yml index fab32b02..3153b633 100644 --- a/roles/usb-install/tasks/main.yml +++ b/roles/usb-install/tasks/main.yml @@ -6,7 +6,7 @@ register: tmpdir - import_role: - name: preseed + name: installer/debian/preseed vars: preseed_tmpdir: "{{ tmpdir.path }}" diff --git a/roles/vm/define/tasks/main.yml b/roles/vm/define/tasks/main.yml index 202644dd..4c2b99e1 100644 --- a/roles/vm/define/tasks/main.yml +++ b/roles/vm/define/tasks/main.yml @@ -23,7 +23,6 @@ name: "{{ hostname }}" command: undefine - - name: define vm virt: command: define diff --git a/roles/vm/define/templates/libvirt-domain.xml.j2 b/roles/vm/define/templates/libvirt-domain.xml.j2 index c7e3a2f2..2a2e4388 100644 --- a/roles/vm/define/templates/libvirt-domain.xml.j2 +++ b/roles/vm/define/templates/libvirt-domain.xml.j2 @@ -42,13 +42,14 @@ </rng> {% if vm_define_installer and install_distro == 'openbsd' %} - <disk type='block' device='cdrom'> - <driver name='qemu' type='raw'/> - <source file='{{ installer_path }}/openbsd-{{ install_codename }}/{{ hostvars[hostname].install_cooked.arch | default('amd64') }}/install.iso'/> + <disk type='file' device='cdrom'> + <driver name='qemu'/> + <source file='{{ obsd_autoinstall_tmpdir }}/install.iso'/> <target dev='hdc' bus='ide'/> + <readonly/> </disk> -{% endif %} +{% endif %} {% if 'virtio' in hostvars[hostname].install_cooked.disks %} {% for device, src in hostvars[hostname].install_cooked.disks.virtio.items() %} <disk type='block' device='disk'> diff --git a/roles/vm/host/tasks/main.yml b/roles/vm/host/tasks/main.yml index ef349d4c..0e11da3d 100644 --- a/roles/vm/host/tasks/main.yml +++ b/roles/vm/host/tasks/main.yml @@ -43,10 +43,7 @@ fstype: "{{ installer_lvm.fs }}" state: mounted -- name: make sure installer directories exists - loop: - - "{{ installer_path }}" - - "{{ preseed_path }}" +- name: make sure installer directory exists file: - name: "{{ item }}" + name: "{{ installer_path }}" state: directory diff --git a/roles/vm/install/meta/main.yml b/roles/vm/install/meta/main.yml deleted file mode 100644 index 710f90ad..00000000 --- a/roles/vm/install/meta/main.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -dependencies: - - role: installer/debian - distros: - - distro: "{{ install_distro }}" - codename: "{{ install_codename }}" - arch: [ "{{ hostvars[hostname].install_cooked.arch | default('amd64') }}" ] diff --git a/roles/vm/install/tasks/main.yml b/roles/vm/install/tasks/main.yml index 162ece24..20484401 100644 --- a/roles/vm/install/tasks/main.yml +++ b/roles/vm/install/tasks/main.yml @@ -28,16 +28,26 @@ state: directory register: tmpdir - - import_role: - name: preseed + - when: install_distro in ['debian', 'ubuntu'] vars: ssh_keys_root: "{{ hostvars[hostname].ssh_keys_root }}" preseed_tmpdir: "{{ tmpdir.path }}" preseed_force_net_ifnames_policy: path preseed_no_netplan: yes install_interface: enp1s1 + import_role: + name: installer/debian/preseed + + - when: install_distro in ['openbsd'] + vars: + ssh_keys_root: "{{ hostvars[hostname].ssh_keys_root }}" + obsd_autoinstall_tmpdir: "{{ tmpdir.path }}" + obsd_autoinstall_serial_device: com0 + install_interface: vio0 + import_role: + name: installer/openbsd/autoinstall - - name: Make preseed workdir readable by qemu + - name: Make installer workdir readable by qemu acl: path: "{{ tmpdir.path }}" state: present @@ -54,6 +64,15 @@ - debug: msg: "you can check on the status of the installer running this command 'virsh console {{ hostname }}' on host {{ inventory_hostname }}." + - when: installer_manual_steps_msg is defined + pause: + prompt: | + Mind that this installer needs manual steps to be performed: + + {{ installer_manual_steps_msg | indent(2) }} + + When done press enter to continue or Ctrl-C + 'A' to abort. + - name: wait for installer to finish or crash wait_for_virt: name: "{{ hostname }}" diff --git a/roles/zsh/tasks/main.yml b/roles/zsh/tasks/main.yml index 80880f83..a5ae60ec 100644 --- a/roles/zsh/tasks/main.yml +++ b/roles/zsh/tasks/main.yml @@ -1,13 +1,21 @@ --- -- name: install zsh packages - apt: +- name: load os/distrubtion/version specific variables + include_vars: "{{ item }}" + with_first_found: + - files: + - "{{ ansible_distribution_release }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + +- name: install zsh package + package: name: zsh state: present - name: install zsh-config loop: - src: "zshrc" - dest: "/etc/zsh/zshrc" + dest: "{{ zsh_conf_base_dir }}/zshrc" - src: "zshrc.skel" dest: "/etc/skel/.zshrc" loop_control: @@ -20,19 +28,17 @@ loop: "{{ [ 'root' ] | union(zsh_loginshell_user | default([])) }}" user: name: "{{ item }}" - shell: /bin/zsh - -- name: make zsh the default shell for useradd - lineinfile: - regexp: '^#?SHELL=' - line: 'SHELL=/bin/zsh' - path: /etc/default/useradd + shell: "{{ zsh_bin_path }}" -- name: make zsh the default shell for adduser +- name: make zsh the default shell for new users + loop: "{{ zsh_default_shell_lineinfile | dict2items }}" + loop_control: + label: "{{ item.key }} ('{{ item.value.regexp }}' -> '{{ item.value.line }}')" lineinfile: - regexp: '^#?DSHELL=' - line: 'DSHELL=/bin/zsh' - path: /etc/adduser.conf + path: "{{ item.key }}" + regexp: "{{ item.value.regexp }}" + line: "{{ item.value.line }}" + create: yes - name: install shell banner when: zsh_banner is defined @@ -46,6 +52,7 @@ - name: enable banner for zsh login lineinfile: - path: /etc/zsh/zlogin + path: "{{ zsh_conf_base_dir }}/zlogin" line: /etc/banner.sh insertbefore: "^## END OF FILE #" + create: yes diff --git a/roles/zsh/templates/banner.chaos-at-home.j2 b/roles/zsh/templates/banner.chaos-at-home.j2 index 74762bbe..c0e71647 100644 --- a/roles/zsh/templates/banner.chaos-at-home.j2 +++ b/roles/zsh/templates/banner.chaos-at-home.j2 @@ -1,4 +1,4 @@ -#!/bin/bash +#!{{ zsh_banner_shell }} echo -e "" echo -e " \033[0;37m █████╗██╗ ██╗ ████╗ █████╗ ██████╗\033[1;30m ██████╗ \033[0;37m██╗ ██╗ █████╗ ███╗ ███╗█████╗\033[0m" diff --git a/roles/zsh/templates/banner.elevate.j2 b/roles/zsh/templates/banner.elevate.j2 index d2c9b907..03dfa73b 100644 --- a/roles/zsh/templates/banner.elevate.j2 +++ b/roles/zsh/templates/banner.elevate.j2 @@ -1,4 +1,4 @@ -#!/bin/bash +#!{{ zsh_banner_shell }} echo -e "" echo -e " \033[1;37m██████████ ██ ██████████ ▜█▙ ▟█▛ ▟██▙ ██████████ ██████████\033[0m" diff --git a/roles/zsh/templates/banner.skillz.j2 b/roles/zsh/templates/banner.skillz.j2 index 8492c918..4c883d22 100644 --- a/roles/zsh/templates/banner.skillz.j2 +++ b/roles/zsh/templates/banner.skillz.j2 @@ -1,4 +1,4 @@ -#!/bin/bash +#!{{ zsh_banner_shell }} echo -e "" echo -e " \033[1;35m███████╗██╗ ██╗██╗██╗ ██╗ ███████╗\033[0;35m ██████╗ ██╗███████╗\033[0m" diff --git a/roles/zsh/templates/banner.spreadspace.j2 b/roles/zsh/templates/banner.spreadspace.j2 index ec59509f..c592804e 100644 --- a/roles/zsh/templates/banner.spreadspace.j2 +++ b/roles/zsh/templates/banner.spreadspace.j2 @@ -1,4 +1,4 @@ -#!/bin/bash +#!{{ zsh_banner_shell }} echo -e "" echo -e " \033[0;33m█████╗█████╗ █████╗ █████╗ ████╗ █████╗ █████╗█████╗ ████╗ ████╗█████╗\033[0m" diff --git a/roles/zsh/vars/Debian.yml b/roles/zsh/vars/Debian.yml new file mode 100644 index 00000000..7138fd2f --- /dev/null +++ b/roles/zsh/vars/Debian.yml @@ -0,0 +1,12 @@ +--- +zsh_banner_shell: /bin/bash +zsh_bin_path: /bin/zsh +zsh_conf_base_dir: /etc/zsh + +zsh_default_shell_lineinfile: + /etc/default/useradd: + regexp: '^#?SHELL=' + line: 'SHELL=/bin/zsh' + /etc/adduser.conf: + regexp: '^#?DSHELL=' + line: 'DSHELL=/bin/zsh' diff --git a/roles/zsh/vars/OpenBSD.yml b/roles/zsh/vars/OpenBSD.yml new file mode 100644 index 00000000..d11fe11e --- /dev/null +++ b/roles/zsh/vars/OpenBSD.yml @@ -0,0 +1,12 @@ +--- +zsh_banner_shell: /bin/ksh +zsh_bin_path: /usr/local/bin/zsh +zsh_conf_base_dir: /etc + +zsh_default_shell_lineinfile: + /etc/usermgmt.conf: + regexp: '^#?shell\s' + line: 'shell /usr/local/bin/zsh' + /etc/adduser.conf: + regexp: '^#?defaultshell=' + line: 'defaultshell=/usr/local/bin/zsh' |