How to run Ansible command when you don't have VM?

 Hello Guys!!

It's less than 5mins to read article

There are different situations where you need to work but you have security restrictions, you cannot even run the vagrant boxes on your laptop. In such situations, If you are able to login to Docker Hub then you can play your playbooks for testing different modules which don't need to connect remotely to your managed nodes. That means you want to execute the module on the Ansible Controller node itself.

Ansible awx Container on Play with Docker
Ansible container running on PWD (Play with Docker)


Pre-requisites

  1. You must have a Docker Hub user account 
  2. You must have basic knowledge on Docker images, containers usage
  3. Good internet speed :)

Steps to run Play with Docker 

Step 1: Log in to your Docker Hub and launch the "Play with Docker" also known as PWD in short.
Step 2: Create the Docker installed Nodes using "ADD NEW INSTANCE".
Step 3: Search for the Ansible images either you can check at the command line with or search on the Docker Hub web page
docker search ansible




Step 4:  Here I've chosen the image as 'ansible/awx', You have your own choices for your Ansible container. Pull the Docker image for Ansible
docker pull ansible/awx

Ansible image pull on Docker Host
Ansible image pull on Docker Host

Step 5: After ansible/awx image pull successful you are good to go for create the ansible container. Use the following command to run the 'myawx' container.

docker run -itd --name myawx ansible/awx

Step 6: Enter into the container name 'myawx' and start playing your playbooks!!
docker exec -it -u 0 myawx /bin/bash
Run and enter into ansible container
Docker run ansible container and ssh to it



Step 7: Now finally,  check the version in the Ansible container
ansible --version
Checking ansible version from awx container
Ansible version checking


Hope you enjoyed this post, please share to your friends it is so simple to understand and execute, you need only internet connection on your laptop!!

You might be interested to see more, This blog is having couple of ansible experiments please visit, given in the right side Content section.  


Comments

Popular posts from this blog

Ansible Jinja2 Templates: A Complete Guide with Examples

Ansible 11 The uri module with examples

Jenkins Active choices parameter - Dynamic input