Run Ansible from any Operating System even Windows

Abdennour Toumi
1 min readOct 18, 2019

Step 1:

Install Docker

Step2:

Alias all Ansible commands by wrapping them with docker container

alias ansible='docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock   -v $(pwd):/code -w /code -e ANSIBLE_CONFIG=/code/ansible.cfg  abdennour/ansible:2.8.5 ansible'alias ansible-playbook='docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock   -v $(pwd):/code -w /code -e ANSIBLE_CONFIG=/code/ansible.cfg abdennour/ansible:2.8.5 ansible-playbook'alias ansible-inventory='docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock   -v $(pwd):/code -w /code -e ANSIBLE_CONFIG=/code/ansible.cfg  abdennour/ansible:2.8.5 ansible-inventory'alias ansible-galaxy='docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock   -v $(pwd):/code -w /code -e ANSIBLE_CONFIG=/code/ansible.cfg  abdennour/ansible:2.8.5 ansible-galaxy'alias ansible-doc='docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock   -v $(pwd):/code -w /code -e ANSIBLE_CONFIG=/code/ansible.cfg  abdennour/ansible:2.8.5 ansible-doc'

Step3 :

Go to your playbook where the file ansible.cfg exist, and run ansible like a boss :

cd /path/to/directory/have/ansible-cfg-file/ansible --versionansible --list-hosts allansible-inventory --graphansible all -m pingansible-playbook .....

--

--

Abdennour Toumi

Software engineer, Cloud Architect, 5/5 AWS|GCP|PSM Certified, Owner of kubernetes.tn