Automated vSphere Provisioning - Workflow Questions
Hi all,
I will try keep this short as it can be a decisive topic. I have searched documentation, github, and this subreddit but I would still like some perspective on what the mature process could look like. I am working on a project to automate our server deployment into a large vSphere environment. I am testing both Terraform and Ansible for this task. The VMs can be highly varied in their memory, CPU, and additional disk resources. There is also the complexity of multiple datastores, datacenters, rpools, and networks.
I am working on minimal viable products of both tools. Initially, I want my team to be able to define their specific needs for 1 or more VMs as simply as possible and press go. I am creating the new VM from a VM template so disk 0 will be standard. All additional disks will be defined and configured with LVM. The end goal is to be able to programmatically generate these template files from a webform, possibly a first step to offering self-service outside of our team.
The biggest thing I am struggling with is the workflow. This is a loose idea of what I am thinking:
- git clone the template and playbooks/terraform files
- admin edits one file (or one file for each vm) from a template in the repo
- The template only includes the things that change, with all of the options in comments.
- admin runs ansible-playbook or terraform init/plan/apply
- tool provisions all of the servers and powers them on
- ansible then configures the servers, looping over all disks after 0 and applying LVM from the template
- vms are dropped in a staging node in configuration management to get our base config, can be moved later to obtain more specific things
Does this make sense? How do I abstract away as much as possible for the configs? One tf or vars file for hardcoded values and another for customization? Or, if ansible, leave them a marked up inventory file?
Thanks in advance. I am excited for this project so I if anyone else has solved this and can point to a mature process or example, I would really appreciate it.
Posted Dec 11, 2019, 10:58 PM UTC
For your Terraform code, make use of modules. Keep a separate repo that does the dirty work for provisioning the VMs. Your individual server/project repos will call your server deployment module. Then anyone writing TF code to deploy a server only needs to write something really simple like this: