226 lines
5.9 KiB
YAML
226 lines
5.9 KiB
YAML
---
|
|
# Plan to Create an Ubuntu VM (ubuntu::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/ubuntu-22.04-autoinstall-wan_verizon.iso"
|
|
staging_ip:
|
|
type: String
|
|
description: "Target VM for post-installation tasks as either public or internal"
|
|
default: "public"
|
|
## 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: "ubuntu22.04"
|
|
# 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: ubuntu::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: ubuntu::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_zabbix
|
|
description: Install Zabbix on the VM
|
|
task: ubuntu::install_zabbix
|
|
targets: $staging_ip
|
|
parameters:
|
|
install_zabbix_bool: $install_zabbix_bool
|
|
|
|
- name: install_docker
|
|
description: Install Docker on the VM
|
|
task: ubuntu::install_docker
|
|
targets: $staging_ip
|
|
parameters:
|
|
install_docker_bool: $install_docker_bool
|
|
|
|
- name: set_moeny_password
|
|
description: Set password for moeny user
|
|
task: ubuntu::set_moeny_password
|
|
targets: $staging_ip
|
|
|
|
- name: set_root_password
|
|
description: Set password for root user
|
|
task: ubuntu::set_root_password
|
|
targets: $staging_ip
|
|
|
|
- name: system_setup
|
|
task: ubuntu::system_setup
|
|
targets: $staging_ip
|
|
parameters:
|
|
ip_with_cidr: $ip_with_cidr
|
|
hostname: $hostname
|
|
dhcp: $dhcp
|
|
gateway_ip: $gateway_ip
|
|
nameserver1: $nameserver1
|
|
nameserver2: $nameserver2
|
|
nameserver3: $nameserver3
|
|
|
|
- name: delete_dns_a_record
|
|
description: Delete existing DNS A record for the VM if it exists
|
|
task: common::delete_dns_a_record
|
|
targets: localhost
|
|
parameters:
|
|
network: $network
|
|
add_a_record_bool: $add_a_record_bool
|
|
dns_hostname: $dns_hostname
|
|
|
|
- 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: delete_dns_a_record_internal
|
|
description: Delete existing internal DNS A record for the VM if it exists
|
|
task: common::delete_dns_a_record_internal
|
|
targets: localhost
|
|
parameters:
|
|
network: $network
|
|
add_a_record_bool: $add_a_record_bool
|
|
dns_hostname: $dns_hostname
|
|
|
|
- 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!"
|