Bolt Terraform Docker Environment (btde)
Puppet Bolt project using Terraform and Docker to create and manage full system containers for local development and testing.
This project is geared towards deploying a Puppet server and agents, but anything's possible.
Requirements
- Only tested on Linux. Welcome contributions to support other OS's!
- Recent version of Puppet Bolt. Tested with 3.26.2.
- Working local docker, recent version, usable by your unprivileged user. Tested with 20.10.17.
Usage
Configuration
- Docker containers are defined in containers.yaml. See local.tf for a list of supported images. Currently only Ubuntu, see [OS Support].
- Terraform variables may be set in inventory.yaml under
vars.terraform. See variables.tf for possible variables and default values.
OS Support
Currently, only Ubuntu LTS 14.04 through 20.04 are supported. Additional images will be added as I need them, or through contributions.
Adding support is relatively straightforward if you're familiar with Dockerfiles.
Relative to the terraform/docker folder:
-
Create a folder under images for the OS name or family. Example: centos
-
Create a
Dockerfilein the OS folder. -
Add the image to the
imagesmap in local.tf. Example:"centos-9" = { name = "btde.local/centos:stream9" dockerfile = "images/centos/Dockerfile" repo = "centos" tag = "stream9" } -
Add an os bootstrap class for the os family if it doesn't exist. See the bootstrap/os/debian class for an example.
Infrastructure
Create
bolt plan run btde::terraform
bolt plan run btde::bootstrapDestroy
bolt plan run btde::terraform destroy=trueView
bolt inventory showNodes
Connect
In addition to basic container setup, the btde::bootstrap plan configures
your local ssh client for easy access to the container infrastructure using
just the container name.
See ~/.ssh/btde_config and the ssh_config plan for details.
ssh puppet-serverProvision
Provision the puppet primary first
ssh puppet-server
puppet apply /etc/puppetlabs/code/environment/production/manifests/site.ppThen any agents can connect to the primary:
ssh puppet-agent
puppet agent -t