This is image contains git and ansible
- -v /playbooks
- -v /root/.ssh
- -v /etc/ansible
- WORKDIR /playbooks
$ docker run --rm -it \
-v $HOME/.ssh:/root/.ssh \
-v $HOME/playbooks:/playbooks \
-v $HOME/playbooks/hosts:/etc/ansible/hosts \
jefferyb/ansible:xenial \
ansible -u $USER remote_server -m ping
$ docker run --rm -it \
-v $HOME/.ssh:/root/.ssh \
-v $HOME/playbooks:/playbooks \
-v $HOME/playbooks/hosts:/etc/ansible/hosts \
jefferyb/ansible:xenial bash
$ ansible -u username remote_server -m ping
and you can start using ansible as normal
Assuming your playbooks are located at $HOME/playbooks
and your hosts file is located at $HOME/playbooks/hosts
, then you can do:
$ alias ansible="docker run --rm -it -v $HOME/.ssh:/root/.ssh -v $HOME/playbooks:/playbooks -v $HOME/playbooks/hosts:/etc/ansible/hosts jefferyb/ansible:xenial ansible -u $USER"
$ ansible remote_server -m ping