Hey!
I’ve been playing around with Terraform lately and It’s amazing! Although, I have few problems which I don’t know how to solve.
Let’s say I want to create an infrastructure of 5 servers, which consist of 2 nomad servers and 3 agents. Now, I’d like to setup this automatically via Terraform so I wouldn’t need to provision and configure each of those servers manually. How can I do that with Terraform? The thing I’m mostly interested in is updating Nomad configuration files on those servers within Terraform (for example: adding new host volumes) without the need to recreate the whole instances.
I’d very appreciate any guidance here!
Cheers!
Hi @sarneeh,
Management of software running inside virtual machines is not typically within Terraform’s scope: its responsibility stops at making sure a virtual machine is running.
Management of the software inside a long-running virtual machine is typically the domain of configuration management software such as Ansible, Chef, Puppet, etc. To use these systems together with Terraform it’s typical to build a custom machine image with the relevant software already installed and then use a platform-specific mechanism to pass that software the relevant information to enroll in the configuration management.
For example, for Amazon EC2 we can use User Data, which is settable in Terraform via the user_data
argument when declaring a single EC2 instance or an autoscaling launch configuration. The base images for various Linux distributions typically include cloud-init as the software to process that extra data, in which case you can use all of the facilities of cloud-init
to pass the necessary configuration information to the installed configuration management software.
1 Like
@apparentlymart Thank you very much for your response!
I did dig around the web to understand the concept better and now I understand what I’ve got wrong - I initially thought that Terraform takes more responsibility, but now it all makes sense.
I have already a plan to use Ansible for my particular case, we’ll see where will it take me
Have a great day!