simpleinfra
simpleinfra copied to clipboard
Add initial support for packer
This adds initial support for running packer with our Ansible setup.
Since the way we handle Ansible configuration is slightly unorthodox (i.e., we have the apply script which allows us to handle multiple environments more easily), we have created a wrapper for packer that sets up the Ansible environment properly. Running this wrapper looks like this:
$ ./packer staging docs-rs-builder
The script works by creating a python virtual environment and copying the proper Ansible configuration into a directory (much in the same way that the apply script does - in fact, I modified the apply script to create the ansible "workspace" through a reuseable function that the new wrapper script uses). It then runs packer build with the correct template.
As a downside, this does require the packer configuration files to be aware of this special environment they're running in and target the correct path for the playbook and inventory file. While I wish this could be more straight forward, this is probably the price we have to pay for supporting multiple environments and running both plain Ansible as well as packer.