Hands-on labs Advanced Free
Terraform & Ansible labs
Seven progressive labs, on a local (KVM) or Proxmox path, around a PHP/MariaDB application.
- 7 labs
- 67 steps
Terraform foundations
3 h 30 10 steps
Define infrastructure as code, understand providers, resources and the plan.
Common steps
-
Step 1 : Identify provider, resource, variable, output and state.
Expected check: explain or show the result in the terminal / the VM.
-
Step 2 : Create a Terraform directory, run fmt/init/validate.
Expected check: explain or show the result in the terminal / the VM.
-
Step 3 : Study terraform plan without provisioning until the plan is approved.
Expected check: explain or show the result in the terminal / the VM.
-
Step 4 : Explain why tfstate and secrets do not go into Git.
Expected check: explain or show the result in the terminal / the VM.
LOCAL - KVM / libvirt
-
Step 5 : Check `virsh list --all` and `virsh net-list --all`; enable the `default` network if needed.
Capture or present the result specific to the local path.
-
Step 6 : Identify the `qemu:///system` URI, the pool and the Ubuntu Cloud image.
Capture or present the result specific to the local path.
-
Step 7 : Initialise the `dmacvicar/libvirt` provider and inspect the local plan.
Capture or present the result specific to the local path.
PROXMOX VE - remote infrastructure
-
Step 8 : Check the Proxmox API endpoint, the token's rights and the TLS certificate.
Capture or present the result specific to the Proxmox path.
-
Step 9 : Identify node_name, datastore, vmbr0, the cloud-init template and the VMID.
Capture or present the result specific to the Proxmox path.
-
Step 10 : Initialise the `bpg/proxmox` provider and analyse the plan without touching existing VMs.
Capture or present the result specific to the Proxmox path.
Resources
Creating the two VMs
3 h 30 10 steps
Provision web-01 and db-01, mastering Cloud-init, SSH and networking.
Common steps
-
Step 1 : Create two distinct VMs, with identifiable CPU/RAM resources.
Expected check: explain or show the result in the terminal / the VM.
-
Step 2 : Inject an SSH key via Cloud-init (never a clear-text password).
Expected check: explain or show the result in the terminal / the VM.
-
Step 3 : Run plan then apply after checking.
Expected check: explain or show the result in the terminal / the VM.
-
Step 4 : Test SSH to both VMs and note the IP addresses.
Expected check: explain or show the result in the terminal / the VM.
LOCAL - KVM / libvirt
-
Step 5 : Create the QCOW2 volumes and the Cloud-init ISOs.
Capture or present the result specific to the local path.
-
Step 6 : Attach the two VMs to the libvirt NAT network via DHCP.
Capture or present the result specific to the local path.
-
Step 7 : Retrieve the IPs via `terraform output -raw web_ip` and `db_ip`.
Capture or present the result specific to the local path.
PROXMOX VE - remote infrastructure
-
Step 8 : Clone the Ubuntu template prepared with Cloud-init.
Capture or present the result specific to the Proxmox path.
-
Step 9 : Adapt the bridge, datastore and two reserved IP addresses.
Capture or present the result specific to the Proxmox path.
-
Step 10 : Check the two VMs in the Proxmox interface and the Terraform outputs.
Capture or present the result specific to the Proxmox path.
Resources
Variables, modules and State
3 h 30 11 steps
Parameterise and industrialise the Terraform resources.
Common steps
-
Step 1 : Change the variables without touching the core of main.tf.
Expected check: explain or show the result in the terminal / the VM.
-
Step 2 : Compare the plan before/after a CPU/RAM change.
Expected check: explain or show the result in the terminal / the VM.
-
Step 3 : Create a reusable module or identify the for_each resources.
Expected check: explain or show the result in the terminal / the VM.
-
Step 4 : Read the state and distinguish state, configuration and reality.
Expected check: explain or show the result in the terminal / the VM.
-
Step 5 : Check destroy without destroying other people's resources.
Expected check: explain or show the result in the terminal / the VM.
LOCAL - KVM / libvirt
-
Step 6 : Change the memory/CPU of the local.machines mapping then apply.
Capture or present the result specific to the local path.
-
Step 7 : Assess the effects of the disk linked to a base QCOW2 image.
Capture or present the result specific to the local path.
-
Step 8 : Check `virsh dominfo tp-web-01` then save the outputs.
Capture or present the result specific to the local path.
PROXMOX VE - remote infrastructure
-
Step 9 : Change the VM's CPU or RAM via variables and plan.
Capture or present the result specific to the Proxmox path.
-
Step 10 : Check the changes proposed in Proxmox.
Capture or present the result specific to the Proxmox path.
-
Step 11 : Explain why the API token stays in the environment, not in tfvars.
Capture or present the result specific to the Proxmox path.
Resources
Ansible foundations
3 h 30 8 steps
Prepare an inventory and run its first idempotent tasks.
Common steps
-
Step 1 : Install Ansible on the control machine.
Expected check: explain or show the result in the terminal / the VM.
-
Step 2 : Create a web/database inventory with the VMs' SSH IPs.
Expected check: explain or show the result in the terminal / the VM.
-
Step 3 : Run `ansible all -m ping` then collect facts.
Expected check: explain or show the result in the terminal / the VM.
-
Step 4 : Write a playbook that installs curl and display its result.
Expected check: explain or show the result in the terminal / the VM.
LOCAL - KVM / libvirt
-
Step 5 : Reuse the two IPs from libvirt; check SSH visibility from the host.
Capture or present the result specific to the local path.
-
Step 6 : Diagnose the libvirt NAT network and SSH keys if unreachable.
Capture or present the result specific to the local path.
PROXMOX VE - remote infrastructure
-
Step 7 : Reuse the IPs configured by Cloud-init on the Proxmox bridge.
Capture or present the result specific to the Proxmox path.
-
Step 8 : Check the VLAN, the Proxmox firewall and SSH access from the machine.
Capture or present the result specific to the Proxmox path.
Resources
Roles, variables and Vault
3 h 30 9 steps
Factor out the Linux configuration and protect the secrets.
Common steps
-
Step 1 : Create and explain the common and docker_engine roles.
Expected check: explain or show the result in the terminal / the VM.
-
Step 2 : Put the shared variables in group_vars/all.yml.
Expected check: explain or show the result in the terminal / the VM.
-
Step 3 : Prepare secrets.yml and encrypt it with ansible-vault.
Expected check: explain or show the result in the terminal / the VM.
-
Step 4 : Run the playbook twice and observe changed/ok.
Expected check: explain or show the result in the terminal / the VM.
-
Step 5 : Explain handlers and Jinja2 templates by going through the roles.
Expected check: explain or show the result in the terminal / the VM.
LOCAL - KVM / libvirt
-
Step 6 : Configure the two local Ubuntu VMs with the same playbook.
Capture or present the result specific to the local path.
-
Step 7 : Check `docker compose version` on each target.
Capture or present the result specific to the local path.
PROXMOX VE - remote infrastructure
-
Step 8 : Configure the two VMs hosted in Proxmox with the same playbook.
Capture or present the result specific to the Proxmox path.
-
Step 9 : Check the differences between SSH privileges and the Proxmox API token.
Capture or present the result specific to the Proxmox path.
Resources
Application deployment
3 h 30 9 steps
Automate MariaDB on db-01 and the application on web-01.
Common steps
-
Step 1 : Reuse the Docker lab's sources in an Ansible role.
Expected check: explain or show the result in the terminal / the VM.
-
Step 2 : Create the two Compose projects (web and DB) with the right variables.
Expected check: explain or show the result in the terminal / the VM.
-
Step 3 : Deploy MariaDB, then the PHP API, frontend, phpMyAdmin and Mailpit.
Expected check: explain or show the result in the terminal / the VM.
-
Step 4 : Test GET /api/hello, a POST message, the DB record and the Mailpit email.
Expected check: explain or show the result in the terminal / the VM.
-
Step 5 : Rerun the playbook and explain the idempotent results.
Expected check: explain or show the result in the terminal / the VM.
LOCAL - KVM / libvirt
-
Step 6 : Use the libvirt private IPs, without exposing MariaDB on a public interface.
Capture or present the result specific to the local path.
-
Step 7 : Test the application via `http://WEB_IP:8080`.
Capture or present the result specific to the local path.
PROXMOX VE - remote infrastructure
-
Step 8 : Use the Proxmox private network and check the firewall rules allowing web-01 → db-01:3306.
Capture or present the result specific to the Proxmox path.
-
Step 9 : Test the frontend and the tools from the administration network.
Capture or present the result specific to the Proxmox path.
Resources
Final workshop: Terraform + Ansible
3 h 30 10 steps
Start again from a blank infrastructure and reproduce the complete deployment.
Common steps
-
Step 1 : Provision two VMs with one controlled Terraform command.
Expected check: explain or show the result in the terminal / the VM.
-
Step 2 : Inject the Terraform IPs into the Ansible inventory.
Expected check: explain or show the result in the terminal / the VM.
-
Step 3 : Run the preparation and deployment playbooks.
Expected check: explain or show the result in the terminal / the VM.
-
Step 4 : Check the frontend, the API, the DB, phpMyAdmin and Mailpit.
Expected check: explain or show the result in the terminal / the VM.
-
Step 5 : Change a variable, rerun and compare the changes.
Expected check: explain or show the result in the terminal / the VM.
-
Step 6 : Document the restoration and carry out a controlled cleanup.
Expected check: explain or show the result in the terminal / the VM.
LOCAL - KVM / libvirt
-
Step 7 : Check there is no libvirt pool/network conflict with the other students.
Capture or present the result specific to the local path.
-
Step 8 : Run the inventory generation script with the local outputs.
Capture or present the result specific to the local path.
PROXMOX VE - remote infrastructure
-
Step 9 : Check the Proxmox account's scope and the VMs reserved for the lab.
Capture or present the result specific to the Proxmox path.
-
Step 10 : Run the inventory generation script from the Proxmox IPs.
Capture or present the result specific to the Proxmox path.
Resources
In the same series Step 2 of 2
- 1 Course Terraform & Ansible — The course
-
2 Lab Terraform & Ansible labs You are here
In the same category
Infrastructure · Intermediate
Docker & Docker Compose — The course
Images, containers, volumes, networks and Compose: vocabulary, essential commands and good practice.
Infrastructure · Intermediate
Kubernetes — The course
Pods, deployments, services, configuration and storage: orchestrating containers, from theory to kubectl.
Infrastructure · Intermediate
Terraform & Ansible — The course
Describe infrastructure with Terraform and configure it with Ansible: providers, playbooks, roles and idempotence.