Docker image to use ansible
and ssh
in a CI ๐
docker run --rm -it gableroux/ansible:5.1.0
.ansible:5.1.0
stage: deploy
when: manual
image: gableroux/ansible:5.1.0
before_script:
# https://docs.gitlab.com/ee/ci/ssh_keys/
- eval $(ssh-agent -s)
- mkdir ~/.ssh/
- chmod 700 ~/.ssh
- echo "$SSH_CONFIG" > ~/.ssh/config
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
deploy-example-master:
<<: *ansible
script:
- ansible --version
- ansible-playbook -i host-example deploy.yml
only:
- master
There is a script in scripts
that reads values from versions.txt
and runs required commands to push to the repository with tags and trigger docker hub. โ๏ธ
Installing with pip
is fine, but pulling this image is faster.
As described here in the short description:
Images for automated testing of Ansible. They do not include Ansible and are not for end users.
The official image is used to run tests for the ansible project. I wish they had and official image for actually running ansible.
Have a look at hub.docker.com/r/gableroux/ansible/tags, most versions are available. There are automatic PRs setup for upgrading the project so the version you're looking for should be there. If for some reason, it's still not there, you can fork the project, replace ENV
and push your own image. Image building is done trough github-actions.
Yes, why not?
I don't trust people when it comes to running critical code against infrastructure. If you wish to use this, I recommend you to fork it and build your own. There are many good alternatives, notably William-Yeh/docker-ansible, but I found it was kind of big or doing too many things. This docker image is based on alpine and is very minimal and small :)
I'm using github-actions. See .github/workflows/