From d6ab88c04d5f283984345cd1433699dab1c29837 Mon Sep 17 00:00:00 2001 From: Tom Lin Date: Mon, 16 Sep 2024 08:12:22 +0100 Subject: [PATCH] Add more options --- README.md | 1 - playbook-vm-idm.yml | 2 +- playbook-vm-login.yml | 2 +- playbook-vm-mgmt.yml | 10 +++++----- playbook-vm-router.yml | 8 ++++---- staging.rb | 12 +++++++++--- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index cf50c14..d3a3412 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,6 @@ ungrouped: pve_username: root@pam pve_password: vagrant pve_node: pve - pve_ip: router_host: router router_password: router_disk_size: 6G diff --git a/playbook-vm-idm.yml b/playbook-vm-idm.yml index 978ec3d..efdfd61 100644 --- a/playbook-vm-idm.yml +++ b/playbook-vm-idm.yml @@ -33,7 +33,7 @@ vm_net: net0: "virtio,bridge=vmbr1" vm_scsi: - scsi0: "{{storage_pool}}:0,import-from=/var/lib/vz/template/bos.x86_64.{{idm_disk_size}}.qcow2,format=qcow2,cache=none,ssd=1,discard=on" + scsi0: "{{storage_pool}}:0,import-from=/var/lib/vz/template/bos.x86_64.{{idm_disk_size}}.qcow2,format={{disk_format}},cache=none,ssd=1,discard=on" - include_tasks: tasks/pve_vm_state.yml vars: { vm_name: "idm.{{domain}}", vm_state: started } diff --git a/playbook-vm-login.yml b/playbook-vm-login.yml index 3bc1884..e75e6cb 100644 --- a/playbook-vm-login.yml +++ b/playbook-vm-login.yml @@ -45,7 +45,7 @@ vm_net: net0: "virtio,bridge=vmbr1" vm_scsi: - scsi0: "{{storage_pool}}:0,import-from=/var/lib/vz/template/bos.{{item}}.{{login_disk_size}}.qcow2,format=qcow2,cache=none,ssd=1,discard=on" + scsi0: "{{storage_pool}}:0,import-from=/var/lib/vz/template/bos.{{item}}.{{login_disk_size}}.qcow2,format={{disk_format}},cache=none,ssd=1,discard=on" loop: [x86_64, aarch64] - name: Patch up aarch64 login nodes diff --git a/playbook-vm-mgmt.yml b/playbook-vm-mgmt.yml index 7b45ee3..e5b6423 100644 --- a/playbook-vm-mgmt.yml +++ b/playbook-vm-mgmt.yml @@ -32,7 +32,7 @@ changed_when: false - set_fact: - rds1_disk_spec: "{{storage_pool}}:0,import-from={{mgmt_rds_disk}},format=qcow2,serial=rds1" + rds1_disk_spec: "{{storage_pool}}:0,import-from={{mgmt_rds_disk}},format={{disk_format}},serial=rds1" when: "'QEMU QCOW Image' in mgmt_rds_file_type.stdout" - set_fact: @@ -53,7 +53,7 @@ vm_net: net0: "virtio,bridge=vmbr1" vm_scsi: - scsi0: "{{storage_pool}}:0,import-from=/var/lib/vz/template/bos.x86_64.{{mgmt_disk_size}}.qcow2,format=qcow2,cache=none,ssd=1,discard=on" + scsi0: "{{storage_pool}}:0,import-from=/var/lib/vz/template/bos.x86_64.{{mgmt_disk_size}}.qcow2,format={{disk_format}},cache=none,ssd=1,discard=on" scsi1: "{{rds1_disk_spec}}" - include_tasks: tasks/pve_vm_state.yml @@ -86,7 +86,7 @@ ansible.builtin.copy: dest: "/etc/crypttab" content: | - rds1 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_rds1-part1 /boot/luks.key luks,nofail + rds1 {{mgmt_rds_part}} /boot/luks.key luks - name: Setup rds1 mount point ansible.builtin.file: @@ -97,8 +97,8 @@ ansible.posix.mount: path: /mnt/rds1 src: /dev/mapper/rds1 - opts: nofail,uquota - fstype: xfs + opts: "{{mgmt_rds_opts}}" + fstype: "{{mgmt_rds_fstype}}" state: present - name: Reboot diff --git a/playbook-vm-router.yml b/playbook-vm-router.yml index c9a247f..72e2662 100644 --- a/playbook-vm-router.yml +++ b/playbook-vm-router.yml @@ -31,12 +31,12 @@ cores: "{{router_ncores}}" memory: "{{1024 * router_mem_gb}}" net: - net0: "virtio,bridge=vmbr0" - net1: "virtio,bridge=vmbr1" - net2: "virtio,bridge=vmbr2" + net0: "virtio,bridge={{router_inet_wan}}" + net1: "virtio,bridge={{router_inet_lan}}" + net2: "virtio,bridge={{router_inet_mgmt}}" scsihw: "virtio-scsi-single" scsi: - scsi0: "{{storage_pool}}:0,import-from=/var/lib/vz/template/opnsense.amd64.{{router_disk_size}}.qcow2,format=qcow2,cache=none,ssd=1,discard=on" + scsi0: "{{storage_pool}}:0,import-from=/var/lib/vz/template/opnsense.amd64.{{router_disk_size}}.qcow2,format={{disk_format}},cache=none,ssd=1,discard=on" - include_tasks: tasks/pve_vm_state.yml vars: { vm_name: "router.{{domain}}", vm_state: started } diff --git a/staging.rb b/staging.rb index 9076030..23a07dc 100644 --- a/staging.rb +++ b/staging.rb @@ -49,7 +49,8 @@ def self.common_vars(storage_pool) arch_to_dns_map: { x86_64: 'amd64', aarch64: 'arm64' - } + }, + disk_format: 'qcow2' } end @@ -63,8 +64,7 @@ def self.write_inventory(pve_ip:, storage_pool:, extra_hosts:, host_common_hash: pve_vars = { pve_username: 'root@pam', pve_password: 'vagrant', - pve_node: 'pve', - pve_ip: pve_ip + pve_node: 'pve' } router_node_vars = { router_host: 'router', @@ -72,6 +72,9 @@ def self.write_inventory(pve_ip:, storage_pool:, extra_hosts:, host_common_hash: router_disk_size: '6G', router_mem_gb: 2, router_ncores: 4, + router_inet_wan: 'vmbr0', + router_inet_lan: 'vmbr1', + router_inet_mgmt: 'vmbr2', router_ip: '10.10.10.10', router_mgmt_ip: '10.10.20.1', router_mgmt_dhcp_start: '10.10.20.2', @@ -98,6 +101,9 @@ def self.write_inventory(pve_ip:, storage_pool:, extra_hosts:, host_common_hash: mgmt_ncores: 4, mgmt_sshkeys: ssh_keys, mgmt_rds_disk: '/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_rds1', + mgmt_rds_part: '/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_rds1-part1', + mgmt_rds_fstype: 'xfs', + mgmt_rds_opts: 'uquota', mgmt_ip: '10.10.10.102', # following are only used for warewulf config generation mgmt_netmask: '255.255.0.0',