diff options
author | Christian Pointner <equinox@spreadspace.org> | 2020-07-04 17:39:00 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2020-07-04 17:39:00 +0200 |
commit | a1f5550dd6de108f68ea3d6b2a42fe47b49561a4 (patch) | |
tree | c96c0b98bf84f30c192708f765e1cb57b78d46ab | |
parent | remove: ch k8s cluster vms, and hroot-test, add hcloud-test (diff) |
cloud install: support custom partition layout
-rw-r--r-- | inventory/group_vars/emc/main.yml | 2 | ||||
-rw-r--r-- | inventory/group_vars/lendwirbel-live/main.yml | 2 | ||||
-rw-r--r-- | inventory/host_vars/ch-hcloudtest.yml | 21 | ||||
-rw-r--r-- | inventory/host_vars/ch-mimas2.yml | 2 | ||||
-rw-r--r-- | inventory/host_vars/ch-oulu.yml | 3 | ||||
-rw-r--r-- | inventory/host_vars/ele-lt.yml | 2 | ||||
-rw-r--r-- | inventory/host_vars/sk-2019.yml | 3 | ||||
-rw-r--r-- | inventory/host_vars/sk-2019vm.yml | 3 | ||||
-rw-r--r-- | inventory/host_vars/sk-cloudia/vars.yml | 3 | ||||
-rw-r--r-- | inventory/host_vars/sk-tomnext.yml | 3 | ||||
-rw-r--r-- | inventory/hosts.ini | 4 | ||||
-rw-r--r-- | roles/cloud/install/defaults/main.yml | 21 | ||||
-rw-r--r-- | roles/cloud/install/templates/hetzner_installimage.conf.j2 | 14 | ||||
-rw-r--r-- | roles/cloud/install/templates/hetzner_postinst.sh.j2 | 10 |
14 files changed, 69 insertions, 24 deletions
diff --git a/inventory/group_vars/emc/main.yml b/inventory/group_vars/emc/main.yml index 02a2e25c..42515184 100644 --- a/inventory/group_vars/emc/main.yml +++ b/inventory/group_vars/emc/main.yml @@ -5,8 +5,6 @@ install: cloud: credentials: token: "{{ vault_hcloud_api_token }}" - disks: - root_lvm_size: all network: {} diff --git a/inventory/group_vars/lendwirbel-live/main.yml b/inventory/group_vars/lendwirbel-live/main.yml index 43823233..37d3ec1a 100644 --- a/inventory/group_vars/lendwirbel-live/main.yml +++ b/inventory/group_vars/lendwirbel-live/main.yml @@ -12,8 +12,6 @@ install: cloud: credentials: token: "{{ vault_hcloud_api_token }}" - disks: - root_lvm_size: all network: {} diff --git a/inventory/host_vars/ch-hcloudtest.yml b/inventory/host_vars/ch-hcloudtest.yml new file mode 100644 index 00000000..0a2ca334 --- /dev/null +++ b/inventory/host_vars/ch-hcloudtest.yml @@ -0,0 +1,21 @@ +--- +install: + cloud: + credentials: + token: "{{ vault_hcloud_api_token }}" + server_name: "{{ host_name }}" + system_lvm: + size: 13G + volumes: + - name: root + size: 7G + filesystem: ext4 + mountpoint: / + - name: srv + size: 1G + filesystem: ext4 + mountpoint: /srv + mount_options: + - ro + +network: {} diff --git a/inventory/host_vars/ch-mimas2.yml b/inventory/host_vars/ch-mimas2.yml index 46fc78d2..49973cd1 100644 --- a/inventory/host_vars/ch-mimas2.yml +++ b/inventory/host_vars/ch-mimas2.yml @@ -4,8 +4,6 @@ install: credentials: token: "{{ vault_hcloud_api_token }}" server_name: "{{ host_name }}" - disks: - root_lvm_size: all network: {} diff --git a/inventory/host_vars/ch-oulu.yml b/inventory/host_vars/ch-oulu.yml index d0d035d2..e63e6f2d 100644 --- a/inventory/host_vars/ch-oulu.yml +++ b/inventory/host_vars/ch-oulu.yml @@ -2,13 +2,14 @@ install: efi: true disks: - root_lvm_size: 15G primary: software-raid raid: level: 1 members: - /dev/disk/by-id/nvme-Samsung_SSD_970_PRO_1TB_S462NF0M800161Z - /dev/disk/by-id/nvme-Samsung_SSD_970_PRO_1TB_S462NF0M800191M + system_lvm: + size: 15G network: nameservers: diff --git a/inventory/host_vars/ele-lt.yml b/inventory/host_vars/ele-lt.yml index 5ef66f54..1bfcf901 100644 --- a/inventory/host_vars/ele-lt.yml +++ b/inventory/host_vars/ele-lt.yml @@ -3,8 +3,6 @@ install: cloud: credentials: token: "{{ vault_hcloud_api_token }}" - disks: - root_lvm_size: all network: {} diff --git a/inventory/host_vars/sk-2019.yml b/inventory/host_vars/sk-2019.yml index 353fe8c1..23dbbc15 100644 --- a/inventory/host_vars/sk-2019.yml +++ b/inventory/host_vars/sk-2019.yml @@ -10,7 +10,8 @@ install: members: - /dev/nvme0n1 - /dev/nvme1n1 - root_lvm_size: 20G + system_lvm: + size: 20G network: {} diff --git a/inventory/host_vars/sk-2019vm.yml b/inventory/host_vars/sk-2019vm.yml index e989d37e..a131189c 100644 --- a/inventory/host_vars/sk-2019vm.yml +++ b/inventory/host_vars/sk-2019vm.yml @@ -10,7 +10,8 @@ install: members: - /dev/nvme0n1 - /dev/nvme1n1 - root_lvm_size: 10G + system_lvm: + size: 10G network: nameservers: "{{ vm_host.network.dns }}" diff --git a/inventory/host_vars/sk-cloudia/vars.yml b/inventory/host_vars/sk-cloudia/vars.yml index f8167017..0e4e1340 100644 --- a/inventory/host_vars/sk-cloudia/vars.yml +++ b/inventory/host_vars/sk-cloudia/vars.yml @@ -10,7 +10,8 @@ install: members: - /dev/nvme0n1 - /dev/nvme1n1 - root_lvm_size: 15G + system_lvm: + size: 15G network: {} diff --git a/inventory/host_vars/sk-tomnext.yml b/inventory/host_vars/sk-tomnext.yml index 3702bd54..410a1d29 100644 --- a/inventory/host_vars/sk-tomnext.yml +++ b/inventory/host_vars/sk-tomnext.yml @@ -10,7 +10,8 @@ install: members: - /dev/nvme0n1 - /dev/nvme1n1 - root_lvm_size: 10G + system_lvm: + size: 10G network: nameservers: "{{ vm_host.network.dns }}" diff --git a/inventory/hosts.ini b/inventory/hosts.ini index 28fa65d3..751c55a6 100644 --- a/inventory/hosts.ini +++ b/inventory/hosts.ini @@ -25,14 +25,13 @@ 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 ch-nic host_name=nic -ch-hclouttest host_name=hcloud-test +ch-hcloudtest host_name=hcloud-test ch-oulu host_name=oulu host_domain=helsinki.at [chaos-at-home:children] mz-chaos-at-home chaos-at-home-switches chaos-at-home-ap -chaos-at-home-k8s [mz-chaos-at-home] mz-router ansible_host=chmz-router @@ -326,7 +325,6 @@ k8s-emc [kubernetes-cluster:children] k8s-emc k8s-lwl -k8s-chtest [standalone-kubelet] sk-cloudia diff --git a/roles/cloud/install/defaults/main.yml b/roles/cloud/install/defaults/main.yml new file mode 100644 index 00000000..975400a5 --- /dev/null +++ b/roles/cloud/install/defaults/main.yml @@ -0,0 +1,21 @@ +--- +hetzner_boot_size: 512M + +hetzner_system_lvm_size_default: all +hetzner_system_lvm_volumes_default: + - name: root + size: 2560M + filesystem: ext4 + mountpoint: / + - name: var + size: 1280M + filesystem: ext4 + mountpoint: /var + - name: var+log + size: 768M + filesystem: ext4 + mountpoint: /var/log + mount_options: + - noatime + - nodev + - noexec diff --git a/roles/cloud/install/templates/hetzner_installimage.conf.j2 b/roles/cloud/install/templates/hetzner_installimage.conf.j2 index ed22f286..e3cd4c4e 100644 --- a/roles/cloud/install/templates/hetzner_installimage.conf.j2 +++ b/roles/cloud/install/templates/hetzner_installimage.conf.j2 @@ -13,12 +13,14 @@ DRIVE1 {{ install_cooked.disks.primary }} DRIVE1 /dev/sda {% endif %} BOOTLOADER grub -PART /boot ext4 512M -PART lvm {{ host_name }} {{ install_cooked.disks.root_lvm_size }} -{% if install_cooked.disks.root_lvm_size != "all" %} +PART /boot ext4 {{ hetzner_boot_size }} +{% set system_lvm_size = install_cooked.system_lvm.size | default(hetzner_system_lvm_size_default) %} +PART lvm {{ host_name }} {{ system_lvm_size }} +{% if system_lvm_size != "all" %} PART /dummy ext4 all {% endif %} -LV {{ host_name }} root / ext4 2560M -LV {{ host_name }} var /var ext4 1280M -LV {{ host_name }} var+log /var/log ext4 768M +{% set system_lvm_volumes = install_cooked.system_lvm.volumes | default(hetzner_system_lvm_volumes_default) %} +{% for volume in system_lvm_volumes %} +LV {{ host_name }} {{ volume.name }} {{ volume.mountpoint }} {{ volume.filesystem }} {{ volume.size }} +{% endfor %} IMAGE {{ latest_image.stdout }} diff --git a/roles/cloud/install/templates/hetzner_postinst.sh.j2 b/roles/cloud/install/templates/hetzner_postinst.sh.j2 index 613f57ac..d9de15c9 100644 --- a/roles/cloud/install/templates/hetzner_postinst.sh.j2 +++ b/roles/cloud/install/templates/hetzner_postinst.sh.j2 @@ -27,7 +27,12 @@ passwd -d root && passwd -l root {% if install_distro == "debian" %} sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces {% endif %} -sed -r 's#(\s+/var/log\s+ext4\s+)defaults#\1noatime,nodev,noexec#g' -i /etc/fstab +{% set system_lvm_volumes = install_cooked.system_lvm.volumes | default(hetzner_system_lvm_volumes_default) %} +{% for volume in system_lvm_volumes %} +{% if 'mount_options' in volume %} +sed -r 's#(\s+{{ volume.mountpoint }}\s+{{ volume.filesystem }}\s+)defaults#\1{{ volume.mount_options | join(",") }}#g' -i /etc/fstab +{% endif %} +{% endfor %} mkdir -p -m 0700 /target/root/.ssh cat <<EOK > /root/.ssh/authorized_keys @@ -42,7 +47,8 @@ swapoff -a sed -e '/^\/swapfile/d' -i /etc/fstab rm -f /swapfile -{% if install_cooked.disks.root_lvm_size != "all" %} +{% set system_lvm_size = install_cooked.system_lvm.size | default('all') %} +{% if system_lvm_size != "all" %} sed -e '/\/dummy/d' -i /etc/fstab cat > /post-install-finalize <<EOF |