It has been many years of tinkering around with Terraform and Ansible and other configuration management tools when it comes to deploying Veeam software. We can go back 3 years, more since we first started dabbling in the world of using Infrastructure as code to help with the deployment of Veeam.
The above code was using Terraform to deploy the virtual machines and then PowerShell to perform an unattended installation, it worked but there was a better way.
We also dabbled in the world of configuration management to get that installation done with Chef. We go back to 2018 when this Chef Cookbook started life and had a final update in 2020.
Here we are in 2024, I have had a few questions really on any updates to the terraform code and then I stumbled across some work a colleague and community had been working on with Ansible, I want to combine those two and here we are:
What is Terraform?
HashiCorp Terraform is an open-source infrastructure as code (IaC) tool that allows users to define, provision, and manage infrastructure resources in a declarative configuration language.
What is Ansible?
Ansible is an open-source automation tool that simplifies configuration management, application deployment, and task automation across IT environments by using human-readable YAML playbooks.
Why: Terraform & Ansible
Terraform and Ansible can be used together to combine Terraform’s strength in provisioning and managing infrastructure with Ansible’s capability for configuring and automating software deployments, creating a comprehensive solution for infrastructure management and application delivery.
Challenge
The challenge I face is having to repeatedly deploy test or demo environments across vSphere, AWS, Microsoft Azure environments to test and show off capabilities in breakout sessions, meetings etc. I need a way to provision a Veeam environment quickly, efficiently and automated to be able to do this.
Veeam is not a difficult platform to deploy, next, next, next is the way and this works for a large portion of the people out there using the software, but we have some customers that have multiple environments, locations etc that would not want that next next next to be manual so this could work there as well.
My Environments
As mentioned I use them all, but for the sake of this blog we are going to concentrate on vSphere, it is what I use in my home lab and it is what we have in our corporate lab. The goal though is to expand this project out to deploy Veeam components in at least AWS and Microsoft Azure, which is not that big of a step with what we have today.
Getting Started
You will need:
- Terraform installed on a machine
- Ansible installed on your machine
- Details to access your vSphere cluster
To start grab this code base from my GitHub. We are going to start with the file terraform.tfvars this is where our configuration and details are stored for our terraform code base to access and deploy our virtual machines.
As you can see from the above we are going to be adding some details for our vSphere cluster, the templates we wish to use, network configuration and VM configuration. For this stage we only need a Windows Template available the other aspects are to be added later to the overall code.
In this example we are going to deploy two new virtual machines, a VM for Veeam Backup & Replication and a VM for Veeam ONE. Modify this variable list with your configuration.
Ansible, Next
Within the veeam-vsphere-ansible folder you will find the ansible folder, in here you will need to update the inventory.ini file with the IP addresses and details defined in the terraform tfvars file. There is a cleaner way of dealing with this with the Ansible provider for terraform but for now this works.
Probably don’t publish your passwords to GitHub…
We are also going to check our veeam_one.yaml and veeam_vbr.yaml playbooks and make any changes here with the the vars noted here.
Ready to run
Before we get going, we should mention there are many more playbooks that have been created by the community, you can find the Veeam Ansible Playbooks here.
From a ‘terraform plan’ you should see if everything is correct 6 new resources to add, this would be 2 new VMs, a wait command for each of those VMs to become ready and then the ansible playbook for each.
If happy with the output of the terraform plan command then you can get started with the creation of your resources in your environment, depending on your hardware you may want to add some timeouts to the code blocks to increase time. (I might add these and comment them in so you know where to add these breaks)
On my home lab with terrible storage it seemed to take around 2 hours end to end, but in our enterprise lab we are up and running in around 45 minutes.
Next Steps
We are not done, and there are always many improvements we can make here. I want to get to the point where we can easily deploy these veeam components to the other cloud locations. I would like to also then look at deploying additional resources which we saw in the tfvars file, things like proxies and repositories.
The final thing to add to this would be an automated way to apply configuration, create backup jobs from code, add source environments for backup and target storage locations such as S3 buckets. Watch this space.