add vm_destroy playbook and role

correct network addressing in template
write hostname to /etc/hostname
This commit is contained in:
2022-10-30 23:48:43 +13:00
parent 73c9106c8f
commit 50c451e94d
7 changed files with 113 additions and 1 deletions

View File

@ -16,6 +16,7 @@ vm_mac_prefix: "52:54:00:e3:af:"
vm_subnet_prefix: "192.168.199.1" # vm suffix will be appended to this
vm_subnet_suffix: "/24"
vm_gateway: "192.168.199.254"
vm_ntp: "192.168.199.254"
vm_domain: "balsillie.net"
vm_machine_type: "pc-q35-7.1"
vm_machine_arch: "x86_64"

View File

@ -40,6 +40,7 @@
virt-customize --format qcow2 \
-a {{ root_vhd_pool_dir }}/{{ vm_name }}_vda.qcow2 \
--hostname {{ vm_name }}.{{ vm_domain }} \
--write /etc/hostname:{{ vm_name }} \
--upload /tmp/eno1_{{ vm_name }}.network:/etc/systemd/network/10-eno1.network \
--append-line "/etc/hosts:127.0.1.1 {{ vm_name }}.{{ vm_domain }} {{ vm_name }}" \
--password ladmin:password:{{ hostvars[vm_name]['ansible_become_pass'] }} \

View File

@ -1,13 +1,20 @@
[Match]
MACAddress={{ vm_mac_prefix }}{{ vm_number }}
[Link]
ARP=yes
[Address]
{{ vm_subnet_prefix }}{{ vm_number }}{{ vm_subnet_suffix }}
Address={{ vm_subnet_prefix }}{{ vm_number }}{{ vm_subnet_suffix }}
[Route]
Gateway={{ vm_gateway }}
Destination=0.0.0.0/0
Metric=10
[Network]
DHCP=no
LinkLocalAddressing=no
DNS={{ vm_gateway }}
Domains={{ vm_domain }}
NTP={{ vm_ntp }}