|
1 | 1 | # Ansible Playbook Base docker image
|
2 | 2 |
|
3 | 3 | Base docker image for 🎁 ansible playbooks
|
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +See [./example](./example) folder |
| 8 | + |
| 9 | +1. Creare own [Dockerfile](./example/Dockerfile) based on this docker image `docker.io/devincan/ansible-playbook-base:v0.1` |
| 10 | +2. Add your playbooks |
| 11 | +3. Build |
| 12 | +4. Run |
| 13 | + |
| 14 | + |
| 15 | +## Why? |
| 16 | + |
| 17 | +1. 🦾 Modern CI ready. |
| 18 | +2. 🏺 Caching - Ansible roles baked in docker image upfront. |
| 19 | +3. 🎡 Reproducible runs with same ansible, python libraries, roles, ansible.cfg, playbooks. |
| 20 | +4. ⚗️ When you want to run playbooks on Windows |
| 21 | + |
| 22 | +# How does it work? |
| 23 | + |
| 24 | +1. Build docker image including everything needed for playbook to be executed ( Ansible, Python libraries, roles and playbooks ) |
| 25 | +2. Run this docker image with mounted inventory.yml and id_rsa key from you local or CI |
| 26 | +3. Profit 🎩 |
| 27 | + |
| 28 | +## What exaclty base image does? |
| 29 | + |
| 30 | +1. Setup ansible senzible defaults |
| 31 | + |
| 32 | + - [ANSIBLE_INVENTORY](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_INVENTORY) `inventory.yml` |
| 33 | + - [ANSIBLE_FORCE_COLOR](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_FORCE_COLOR) `True` |
| 34 | + - [ANSIBLE_HOST_KEY_CHECKING](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_HOST_KEY_CHECKING) `False` |
| 35 | + - [ANSIBLE_COMMAND_WARNINGS](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_COMMAND_WARNINGS) `False` |
| 36 | + - [ANSIBLE_RETRY_FILES_ENABLED](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_RETRY_FILES_ENABLED) `False` |
| 37 | + - [ANSIBLE_GATHERING](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_GATHERING) `explicit` |
| 38 | + - [ANSIBLE_PRIVATE_ROLE_VARS](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_PRIVATE_ROLE_VARS) `True` |
| 39 | + - [ANSIBLE_REMOTE_USER](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_REMOTE_USER) `pddevops` |
| 40 | + - [ANSIBLE_ROLES_PATH](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_ROLES_PATH) `roles` |
| 41 | + - [ANSIBLE_CALLBACK_WHITELIST](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_CALLBACK_WHITELIST) `profile_tasks` |
| 42 | + - [ANSIBLE_SSH_RETRIES](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_SSH_RETRIES) `10` |
| 43 | + - [ANSIBLE_SSH_CONTROL_PATH](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_SSH_CONTROL_PATH) `/dev/shm/cp%%h-%%p-%%r` |
| 44 | + - [ANSIBE_OPTIONS](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBE_OPTIONS) `"-v"` |
| 45 | + |
| 46 | +2. Add [entrypoint.sh](entrypoint.sh) |
| 47 | + |
| 48 | + This entrypoint will copy baked roles, playbooks and other files from `/ansible-baked` to `/ansible` workdir. Then it will run site.yml playbook. |
| 49 | + |
| 50 | +3. Add essential Python/Ansible dependencies listed in [requirements.txt](./requirements.txt) |
0 commit comments