This Meetup talk covers the configuration of terraform for proxmox and the usage of ansible to configure vms and containers created with terraform on an proxmox system.
Version: 6.3-6
Installation of proxmox is described in the proxmox online documentation and not covered in this repository and talk. Visit first steps üpage of the proxmox website to download the system and get a walkthrough of the installation.
To launch a lxc container we need to setup a image template. Go to local storage > CT Templates and click templates to install one or more container templates.
The project ships a playbook playbook-setup-proxmox.yml to setup the proxmox system with a ubuntu 20.04 cloud init template.
cd ansible
ansible-playbook playbook-setup-proxmox.yml
Version: 0.14.9
Terraform can be installed from the HashiCorp download page.
Next take a look at the README to setup the proxmox provider.tf file in the terraform folder.
Version: 2.9.19
Ansible has an installation guide in its great documentation.
Version: 2.2.14
To avoid installing terraform, ansible and other needed dependecies manually, we prefere a vagrant box that setups the needed software for the current project. Why do with preferre it? Imagin you have different customers running different versions of terraform or ansible to provision and configure their systems, to avoid switching between version, every customer can get a own vagrant box with the need versions to automate their systems.
To use HashiCorp Vagrant you need a virtualization provider. For this sample you need to use virtual box.
If you want to use the vagrant box please connect via ssh.
vagrant ssh
Check if you run the VM template playbook, if not do it now.
cd ansible
ansible-playbook playbook-setup-proxmox.yml
Change to the terraform folder.
cd ~/terraform
Create a file called local.tfvars and add your root@pam password for proxmox
touch local.tfvars
add
pm_password = "your-password"
Init Terroform and run the plan command with your local vars file.
terraform init
terraform plan -var-file=local.tfvars
Provision the VMs with
terraform apply -var-file=local.tfvars
Change to the ansible folder.
cd ~/ansible
First check if ansible is able to connect your vms
ansible-playbook playbook-connection-test.yml
After the check is done and all lights are green we can now configure our k8s cluster.
ansible-playbook playbook-setup-lab.yml
When the configuration is finished we can connect to the master vm and check the nodes or copy the kube config to start interacting with the k8s cluster.
To remove all infrastructe let terrafrom destroy everything.
cd ~/terraform
terraform destroy -var-file=local.tfvars