Stack Overflow Asked on November 20, 2021
My windows-10 has Docker Desktop installed.
I have deployed Ansible image on the Docker by using following command from Dos command prompt :
C:docker pull ansible/ansible:ubuntu1404
And then run using below command :
C:docker run ansible/ansible:ubuntu1404
It is showing that Ansible is up and running in the DockerDesktop Dashboard
Now I wanted to perform following very simple tasks to check whether Ansible is working or not:
I tried using some commands from Ansible container bash terminal, but none of them work.
I also tried using docker run command from my Dos prompt like below, but that did not work too:
c:docker run --rm -it -v /ansible/playbooks ansible/ansible-playbook --version
Please suggest how I can test the above simple tasks to start with.
Conclusion : When you want to create Docker container as your Ansible Control node, you need following simple step to perform:
Answered by SKC on November 20, 2021
I had a look at the Docker-Image ansible/ansible:ubuntu1404.
If you're not able to install Ansible on your workstation, i would recommend you to create your own container with a Ubuntu 20.04 as Base. [2]
Then, you should be able to start your container with a Bash and run the Ansible commands.
Edit: To be more clear, here an example to start with:
Since there is no Docker-Image (which i know) which already has Ansible installed, you could create your own:
Dockerfile:
FROM ubuntu:latest
RUN apt-get update && apt-get install -y ansible
&& rm -rf /var/lib/apt/lists/*
In the directory, where you created the Dockerfile you can execute the docker build: docker build . -t myansible:v01
This will create a Docker-Image with the latest Ubuntu and install Ansible. The Image-Name will be myansible with the tag v01.
After you build your image, you can run it and play with the Ansible command:
#docker run --rm -it myansible:v01 /bin/bash
root@eee0671466ca:/# ansible --version
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]
root@eee0671466ca:/# ansible localhost -m ping
localhost | SUCCESS => {
"changed": false,
"ping": "pong"
}
Answered by CLNRMN on November 20, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP