Skip to content

Latest commit

 

History

History
127 lines (94 loc) · 4.18 KB

README.md

File metadata and controls

127 lines (94 loc) · 4.18 KB

HashiCorp Meetup 2021-04-15

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.

Prepare your system setup

Install Proxmox VE

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.

Install container template

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.

Setup VM template via Ansible

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

Setup Terraform

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.

Setup Ansible

Version: 2.9.19

Ansible has an installation guide in its great documentation.

Setup with Vagrant

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.

Provisioning and Configuration

If you want to use the vagrant box please connect via ssh.

vagrant ssh

Check VM template

Check if you run the VM template playbook, if not do it now.

cd ansible
ansible-playbook playbook-setup-proxmox.yml

Provision VMs with Terraform

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

Configure VMs with Ansible

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.

Clean up

To remove all infrastructe let terrafrom destroy everything.

cd ~/terraform
terraform destroy -var-file=local.tfvars

Useful Links