Table of Contents
Creating and Deploying Debian via Cloud-Init and Terraform
Prepare the Template Image
1. On the Proxmox cluster, Prepare a Debian image via a Netinstall installation with the base configuration (user, sudo, vim only) and install the cloud-init package on the system.
2. Once the image is set up, run “qm set {VM Number} –ide2 local-lvm:cloudinit”, “qm set {VM Number} –serial0 socket –vga serial0” to add the cloud init volume and serial connection required.
3. Convert the image to a template. On our current infrastructure this template should be set up on each node, but would only be required once on one with shared VM storage. To set up the image on another template use zfs send and receive.
Deploy the Image with Terraform
1. Log into Ansible as the sysadmin user
2. Run the terraform-vm-generator.py python script. This script takes a list of VMs, as well as other configuration information, and preallocates a DHCP address for each VM, then produces a Terraform Configuration File
3. Place this configuration file in a folder, along with main.cf
4. Run terraform init to initialize the folder
5. Run terraform plan to confirm the deployment
6. Run terraform apply to push the configuration
Configure With Ansible
On the same server, take the list of hosts and place it in the ansible folder. Define a role if necessary, and then run ansible-playbook to set up the machines
Removing VMs
TODO
Longer Term TODO
1. Investigate whether Terraform can be run through CI/CD so this can all be done entirely through a git repository