Very easy to install Docker Desktop on the Mac and loving it. I’m learning Docker so much easier not worrying about if I have access to a server with Docker or spinning up a VM or Parallels session to work wit Docker. Its now all local on my macbook to include all the terminal commands.
Once Docker Desktop is installed, let’s install Ansible
How to deploy Ansible inside a Docker container
Deploying Ansible inside a Docker container is an easy way to have a lightweight, agile environment for using Ansible. In this post, we will take a look at how to get Ansible up and running inside a Docker container on a container host.
There is no question that containerized applications provide a tremendous advantage over traditionally installed applications in the data center. Using containers to run automation and configuration management tools can provide flexibility in deploying and running these applications. Here we see how the very popular automation and configuration management tool, Ansible, can easily be deployed and run from a Docker container.
What is Ansible?
In case you have not run across Ansible as an Infrastructure-as-Code (IaC) tool, it is a great way to get started automating the infrastructure in your environment. Ansible provides an easy way to install applications, provide configuration management, and achieve continuous delivery. It allows you to interact with the various types of infrastructure in your environment by using easy-to-understand YAML playbooks.
Ansible provides a great way to detect and correct configuration “drift” in your environment. You can easily integrate your Ansible YAML code into Git for proper version control as well. It can connect to your Linux and Windows servers without the need to deploy agents, and you can do it with very simple, easy-to-understand text files that make up your playbooks.
First check to make sure Docker is installed
docker --version
Creating a Dockerfile
To build a Docker container image that will be used to run Ansible, you need to build a Dockerfile. The Dockerfile contains the directives that Docker uses to build the actual Docker container image along with the specified components.
To build the Dockerfile, I am creating the file “Dockerfile” in my home directory on my Mac OSX. It contains the components needed for Ansible as well as a few other modules that are used for connecting and managing a Windows environment with Kerberos.
You can add and adjust the following as needed for your environment: