bolt/vm_automation/alpine/plans/create_vm.yaml

232 lines
5.9 KiB
YAML

---
# Plan to Create an Alpine VM (alpine::create_vm)
parameters:
target_host:
type: String
description: "Target host to create the VM on"
default: "vortex"
## Main Configurations
vm_name:
type: String
description: "Name of the VM"
default: "vm-template-staging"
# Network Configuration
hostname:
type: String
description: "Hostname of the VM"
default: "vm-template-staging"
network:
type: String
description: "Network to connect the VM to"
default: "wan-verizon"
ip_with_cidr:
type: String
description: "Public IP of the VM"
default: "100.40.223.190/24"
gateway_ip:
type: String
description: "Gateway IP for the VM"
default: "100.40.223.1"
# Define Based on Whether Public or Internal VM
iso_path:
type: String
description: "Path to the ISO file"
default: "/mnt/nfs/kvm-isos/iso-build/alpine-autoinstall-wan_verizon.iso"
staging_ip:
type: String
description: "Staging IP"
default: "100.40.223.190"
## Optional Configurations
# Zabbix
install_zabbix_bool:
type: Boolean
description: "Whether to install Zabbix on the VM"
default: true
# Docker
install_docker_bool:
type: Boolean
description: "Whether to install Docker on the VM"
default: true
# DNS
add_a_record_bool:
type: Boolean
description: "Whether to add a DNS A record for the VM"
default: false
dns_hostname:
type: String
description: "Hostname for the DNS A record"
default: "vm-template-staging"
dns_ttl:
type: Integer
description: "TTL for the DNS A record"
default: 3600
## Rarely Changed Configurations
# VM Specifications
ram:
type: Integer
description: "Amount of RAM in MB"
default: 8192
vcpus:
type: Integer
description: "Number of virtual CPUs"
default: 4
disk_size:
type: Integer
description: "Size of the disk in GB"
default: 100
disk_path:
type: String
description: "Base path for disk images"
default: "/mnt/nfs/moeny-images"
os_variant:
type: String
description: "OS variant for the VM"
default: "alpinelinux3.20"
# Rarely Changed Network Configuration
dhcp:
type: Boolean
description: "Enable DHCP on the VM"
default: false
nameserver1:
type: String
description: "Primary nameserver for the VM"
default: "8.8.8.8"
nameserver2:
type: String
description: "Secondary nameserver for the VM"
default: "8.8.4.4"
nameserver3:
type: String
description: "Tertiary nameserver for the VM"
default: "1.1.1.1"
steps:
- name: validate_parameters
description: Validate all input parameters before proceeding
task: alpine::validate_vm_parameters
targets: localhost
parameters:
target_host: $target_host
vm_name: $vm_name
hostname: $hostname
network: $network
ip_with_cidr: $ip_with_cidr
gateway_ip: $gateway_ip
iso_path: $iso_path
staging_ip: $staging_ip
dns_hostname: $dns_hostname
dns_ttl: $dns_ttl
ram: $ram
vcpus: $vcpus
disk_size: $disk_size
disk_path: $disk_path
os_variant: $os_variant
nameserver1: $nameserver1
nameserver2: $nameserver2
nameserver3: $nameserver3
- name: check_ip_availability
description: Check if the target IP is already in use
task: common::check_ip_availability
targets: localhost
parameters:
network: $network
- name: create_vm
task: alpine::create_vm
targets: $target_host
parameters:
iso_path: $iso_path
vm_name: $vm_name
ram: $ram
vcpus: $vcpus
disk_size: $disk_size
disk_path: "${disk_path}/${vm_name}.qcow2"
network: $network
os_variant: $os_variant
- name: install_alpine
description: Install Alpine OS on the VM
task: alpine::install_alpine
targets: localhost
parameters:
vm_name: $vm_name
disk_path: "${disk_path}/${vm_name}.qcow2"
staging_ip: $staging_ip
gateway_ip: $gateway_ip
- name: install_packages
description: Install Packages on the VM
task: alpine::install_packages
targets: localhost
parameters:
staging_ip: $staging_ip
- name: install_zabbix
description: Install Zabbix on the VM
task: alpine::install_zabbix
targets: localhost
parameters:
install_zabbix_bool: $install_zabbix_bool
staging_ip: $staging_ip
- name: install_docker
description: Install Docker on the VM
task: alpine::install_docker
targets: localhost
parameters:
install_docker_bool: $install_docker_bool
staging_ip: $staging_ip
- name: set_moeny_password
description: Set password for moeny user
task: alpine::set_moeny_password
targets: localhost
parameters:
staging_ip: $staging_ip
- name: set_root_password
description: Set password for root user
task: alpine::set_root_password
targets: localhost
parameters:
staging_ip: $staging_ip
- name: system_setup
task: alpine::system_setup
targets: localhost
parameters:
ip_with_cidr: $ip_with_cidr
hostname: $hostname
dhcp: $dhcp
gateway_ip: $gateway_ip
nameserver1: $nameserver1
nameserver2: $nameserver2
nameserver3: $nameserver3
staging_ip: $staging_ip
- name: add_dns_a_record
description: Add a DNS A record for the VM
task: common::add_dns_a_record
targets: localhost
parameters:
network: $network
add_a_record_bool: $add_a_record_bool
ip_with_cidr: $ip_with_cidr
dns_hostname: $dns_hostname
dns_ttl: $dns_ttl
- name: add_dns_a_record_internal
description: Add an Internal DNS A record for the VM
task: common::add_dns_a_record_internal
targets: localhost
parameters:
network: $network
add_a_record_bool: $add_a_record_bool
ip_with_cidr: $ip_with_cidr
dns_hostname: $dns_hostname
dns_ttl: $dns_ttl
return:
message: "VM ${vm_name} created and updated successfully!"