This docker container is used for provisioning clusters in AWS using Terraform and Ansible. It creates a work and test environment for working with Infrastructure-as-Code.
Latest version of Centos is used to create this container. In the container, awscli, ansible, terraform and consul are installed, consul local server is started and git2consul service is started to fetch configuration from another git repository. The latter comes in handy when automatization takes place and the parameters fed to the infrastructure-as-code scripts define the properties of the infrastructure you wish to build.
-
Start Docker in Windows.
-
Open PowerShell.
-
Step into
docker-on-wins-hashistack
folder. -
Create a file
aws_cred.env
and putAWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
in them. Usekey=value
format. This file is used in thedocker build
line. -
Create a file
id_rsa
in foldercopy_files
and add the private key to connect to the EC2 instances in AWS. This file is copied to the container in DockerFile. -
File
copy_files/encrypt_consul.json
holds a 16-bytes, Base64 encoded key for encrypting traffic between consul servers and agents. -
Create image by running
docker build . --tag=hashistack-image
-
Create container based on the image
docker run -itd --rm -p8500:8500 --name hashistack --hostname terraformer -v C:\marko\GitHub:/local-git --env-file "env_files/env.list" --env-file "env_files/aws_cred.env" hashistack-image
Option
-v
maps the github repository on Windows drive to a folder in the container. Port8501
is opened so that the Consul web UI can be reached from a web browser in Windows. -
Start container
docker exec -it hashistack bash
Once in the container:
- Check
localhost:8500
in your web browser to see if Consul is running. - Type
terraform
to see if terraform is installed. - Type
aws
to see if awscli is installed. - Type
ansible
to see if ansible is installed.
If container should be recreated based on an updated image, stop the container by running
docker stop hashistack
Now the new container, with the same name, can be created.