Run Ansible anywhere, using Docker
Run Ansible on Windows, MacOS and Linux via Docker.
Join our Slack community, ask questions, contribute, get help!
As part of DevOps Pass AI project we needed integration for Ansible, which will work on all platforms in the same way, including Windows, MacOS and Linux. As you probably know Ansible is not suported natively on Windows - https://docs.ansible.com/ansible/latest/os_guide/windows_faq.html#can-ansible-run-on-windows
Inspired by tofuutils/tenv been created DOP-AVM (DevOps Pass AI Ansible Version Manager).
It uses Docker under the hood and allowing you to run Ansible tools from your local without installation of Python and on Windows.
# Linux
curl -sL $(curl -s https://api.github.com/repos/devopspass/dop-avm/releases/latest | grep "https.*linux_amd64" | awk '{print $2}' | sed 's/"//g') | tar xzvf - dop-avm
# MacOS
curl -sL $(curl -s https://api.github.com/repos/devopspass/dop-avm/releases/latest | grep "https.*darwin_amd64" | awk '{print $2}' | sed 's/"//g') | tar xzvf - dop-avm
sudo mv dop-avm /usr/local/bin/
sudo sh -c "cd /usr/local/bin/ && dop-avm setup"
Download latest binary for Windows - https://github.com/devopspass/dop-avm/releases/
tar xzf dop-avm*.tar.gz
md %USERPROFILE%\bin
move dop-avm.exe %USERPROFILE%\bin\
setx PATH "%USERPROFILE%\bin;%PATH%"
cd %USERPROFILE%\bin\
dop-avm setup
In DOP you can add Ansible app and run action Install Ansible Version Manager, it will download and install dop-avm
.
dop-avm
copying own binary with different names, which will be used later by user:
- ansible
- ansible-playbook
- ansible-galaxy
- ansible-vault
- ansible-doc
- ansible-config
- ansible-console
- ansible-inventory
- ansible-adhoc
- ansible-lint
- molecule
When you're running any of this command, it will run Docker container devopspass/ansible:latest
and binary inside (source Dockerfile in repo).
AVM will pass environment variables from host machine:
ANSIBLE_*
MOLECULE_*
GALAXY_*
AWS_*
GOOGLE_APPLICATION_CREDENTIALS
Plus volumes (if exist):
.ssh
.aws
.azure
.ansible
And services, like SSH-agent and Docker socket. As a result you can run Ansible on Windows, MacOS and Linux via Docker without installation of Python and Ansible on your local, especially it's useful for Windows where it's not possible to run Ansible at all.
Probably you may have Docker container built in your organization, which is used in pipelines or recommended for local, you can use it by specifying DOP_AVM_IMAGE_NAME
environment variable. Be sure that all necessary binaries, like molecule
are inside, when you're running it.