refactor ♻️: Refactored the Debian VM template and cloning tasks for improved readability and maintainability.
Improved the structure and organization of the tasks to make it easier to understand and modify. Added comments and whitespace to enhance readability.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
---
|
||||
vm_id: 150
|
||||
hostname: debian-template-base
|
||||
|
||||
@@ -6,48 +7,73 @@ cores: 4
|
||||
bridge: vmbr0
|
||||
storage: local-lvm
|
||||
cpu_type: host
|
||||
mac_address: "DE:AD:BE:EF:44:55"
|
||||
|
||||
# Networking for template VM
|
||||
ip_mode: dhcp
|
||||
ipconfig0: "ip=dhcp"
|
||||
# Default MAC generator: avoids collisions
|
||||
mac_base: "DE:AD:BE"
|
||||
mac_suffix: "{{ '%02X:%02X' | format((vm_id // 256) % 256, vm_id % 256) }}"
|
||||
mac_address: "{{ mac_base }}:{{ mac_suffix }}"
|
||||
|
||||
###############
|
||||
# Networking
|
||||
###############
|
||||
ip_mode: dhcp # or static
|
||||
ip_address: "192.168.1.60/24"
|
||||
gateway: "192.168.1.1"
|
||||
dns:
|
||||
- "1.1.1.1"
|
||||
- "8.8.8.8"
|
||||
|
||||
ipconfig0: "{{ 'ip=dhcp' if ip_mode == 'dhcp' else 'ip=' + ip_address + ',gw=' + gateway }}"
|
||||
|
||||
###############
|
||||
# Packages
|
||||
###############
|
||||
packages:
|
||||
- qemu-guest-agent
|
||||
- curl
|
||||
- htop
|
||||
|
||||
###############
|
||||
# Cloud-Init user + SSH + password
|
||||
###############
|
||||
ci_user: debian
|
||||
ci_password: "SecurePass123"
|
||||
ci_password: "SecurePass123" # consider vault
|
||||
ssh_key_path: "~/.ssh/id_rsa.pub"
|
||||
timezone: "Europe/Berlin"
|
||||
|
||||
###############
|
||||
# Optional Disk Resize
|
||||
###############
|
||||
resize_disk: true
|
||||
resize_size: "16G"
|
||||
|
||||
###############
|
||||
# GPU Options
|
||||
###############
|
||||
gpu_passthrough: false
|
||||
gpu_device: "0000:01:00.0"
|
||||
virtio_gpu: false
|
||||
|
||||
###############
|
||||
# TPM + Secure Boot
|
||||
###############
|
||||
enable_tpm: false
|
||||
|
||||
##########################
|
||||
# NEW OPTIONS
|
||||
##########################
|
||||
|
||||
# Convert VM to template?
|
||||
make_template: true
|
||||
|
||||
# Create clones from the template?
|
||||
create_clones: true
|
||||
|
||||
# List of clones to generate
|
||||
# List of clones
|
||||
clones:
|
||||
- id: 301
|
||||
hostname: app01
|
||||
ip: "192.168.1.81/24"
|
||||
gateway: "192.168.1.1"
|
||||
|
||||
full: 1
|
||||
- id: 302
|
||||
hostname: app02
|
||||
ip: "192.168.1.82/24"
|
||||
gateway: "192.168.1.1"
|
||||
full: 0
|
||||
|
||||
Reference in New Issue
Block a user