{"id":13700663,"url":"https://github.com/William-Yeh/docker-ansible","last_synced_at":"2025-05-04T19:33:17.908Z","repository":{"id":31116997,"uuid":"34676511","full_name":"William-Yeh/docker-ansible","owner":"William-Yeh","description":"Docker images for Ansible software, installed in a selected Linux distributions (Debian/Ubuntu/CentOS/Alpine).","archived":false,"fork":false,"pushed_at":"2020-07-25T07:54:08.000Z","size":132,"stargazers_count":402,"open_issues_count":21,"forks_count":158,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-08-03T20:09:09.896Z","etag":null,"topics":["ansible","docker"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/williamyeh/ansible/","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/William-Yeh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-27T16:02:03.000Z","updated_at":"2024-07-29T07:14:20.000Z","dependencies_parsed_at":"2022-07-14T23:30:42.206Z","dependency_job_id":null,"html_url":"https://github.com/William-Yeh/docker-ansible","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/William-Yeh%2Fdocker-ansible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/William-Yeh%2Fdocker-ansible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/William-Yeh%2Fdocker-ansible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/William-Yeh%2Fdocker-ansible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/William-Yeh","download_url":"https://codeload.github.com/William-Yeh/docker-ansible/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224406065,"owners_count":17305718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","docker"],"created_at":"2024-08-02T20:00:59.882Z","updated_at":"2024-11-13T06:31:26.695Z","avatar_url":"https://github.com/William-Yeh.png","language":"Dockerfile","funding_links":[],"categories":["Dockerfile","docker"],"sub_categories":[],"readme":"Docker-Ansible base images\n===================\n\n[![Circle CI](https://circleci.com/gh/William-Yeh/docker-ansible.svg?style=shield)](https://circleci.com/gh/William-Yeh/docker-ansible) [![Build Status](https://travis-ci.org/William-Yeh/docker-ansible.svg?branch=master)](https://travis-ci.org/William-Yeh/docker-ansible)\n\n\n## Summary\n\nRepository name in Docker Hub: **[williamyeh/ansible](https://hub.docker.com/r/williamyeh/ansible/)**\n\nThis repository contains Dockerized [Ansible](https://github.com/ansible/ansible), published to the public [Docker Hub](https://hub.docker.com/) via **automated build** mechanism.\n\n\n\n## Configuration\n\nThese are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions.\n\n### Base OS\n\nDebian (stretch, jessie), Ubuntu (bionic, xenial, trusty), CentOS (7), Alpine (3).\n\nSupports for Wheezy, Precise, and CentOS6 have been ended since Sep 2017.\n\n### Ansible\n\nFour versions are provided:\n\n  1. provides the most recent *stable* version of Ansible; suitable for most people.\n  2. same as stable version, but is designed for building (near-)*minimal* images out of playbooks; i.e., the Ansible body will be removed when mission completed. Refer to “[Build Docker images with Ansible: A half-blood approach](https://github.com/William-Yeh/build-docker-with-ansible)” for working examples and slides.\n  3. provides the old 1.9 version of Ansible (but will be retired someday).\n  4. provides the *experimental* version of Ansible; i.e., the master branch of official [Ansible's git repo](https://github.com/ansible/ansible).\n\nEach version is further divided into two variants:\n\n- *Normal* variant: intended to be used as Ansible *control machines*, or in cases that is inadequate in the onbuild variants.\n- *Onbuild* variant: intended to be used to build Docker images.\n\n\n## Images and tags\n\n### Stable version (installed from official PyPI repo):\n\n- Normal variants:\n\n  - `williamyeh/ansible:debian9`\n  - `williamyeh/ansible:debian8`\n  - `williamyeh/ansible:ubuntu18.04`\n  - `williamyeh/ansible:ubuntu16.04`\n  - `williamyeh/ansible:ubuntu14.04`\n  - `williamyeh/ansible:centos7`\n  - `williamyeh/ansible:alpine3`\n\n- Onbuild variants (*recommended for common cases*):\n\n  - `williamyeh/ansible:debian9-onbuild`\n  - `williamyeh/ansible:debian8-onbuild`\n  - `williamyeh/ansible:ubuntu18.04-onbuild`\n  - `williamyeh/ansible:ubuntu16.04-onbuild`\n  - `williamyeh/ansible:ubuntu14.04-onbuild`\n  - `williamyeh/ansible:centos7-onbuild`\n  - `williamyeh/ansible:alpine3-onbuild`\n\n\n### Minimal configuration (the Ansible body will be removed when mission completed):\n\nRefer to “[Build Docker images with Ansible: A half-blood approach](https://github.com/William-Yeh/build-docker-with-ansible)” for working examples and slides.\n\n- Onbuild variants:\n\n  - `williamyeh/ansible:mini-alpine3`\n  - `williamyeh/ansible:mini-debian9`\n  - `williamyeh/ansible:mini-debian8`\n\n\n### Old 1.9 version (will be retired someday):\n\nNote: Ansible 1.9 was not supported in CentOS EPEL since January 2017, according to [this announcement](http://www.spinics.net/linux/fedora/epel-devel/msg00792.html).\n\n- Normal variants:\n\n  - `williamyeh/ansible:1.9-debian8`\n  - `williamyeh/ansible:1.9-ubuntu14.04`\n  - `williamyeh/ansible:1.9-alpine3`\n\n- Onbuild variants (*recommended for common cases*):\n\n  - `williamyeh/ansible:1.9-debian8-onbuild`\n  - `williamyeh/ansible:1.9-ubuntu14.04-onbuild`\n  - `williamyeh/ansible:1.9-alpine3-onbuild`\n\n\n### Experimental version (building directly from the git `master` source tree; use at your own risk!):\n\n- Normal variants:\n\n  - `williamyeh/ansible:master-debian9`\n  - `williamyeh/ansible:master-debian8`\n  - `williamyeh/ansible:master-ubuntu18.04`\n  - `williamyeh/ansible:master-ubuntu16.04`\n  - `williamyeh/ansible:master-centos7`\n\n- Onbuild variants (*recommended for common cases*):\n\n  - `williamyeh/ansible:master-debian9-onbuild`\n  - `williamyeh/ansible:master-debian8-onbuild`\n  - `williamyeh/ansible:master-ubuntu18.04-onbuild`\n  - `williamyeh/ansible:master-ubuntu16.04-onbuild`\n  - `williamyeh/ansible:master-centos7-onbuild`\n\n\n\n## For the impatient\n\nHere comes a simplest working example for the impatient.\n\nFirst, choose a base image you'd like to begin with. For example, `williamyeh/ansible:ubuntu16.04-onbuild`.\n\nSecond, put the following `Dockerfile` along with your playbook directory:\n\n```\nFROM williamyeh/ansible:ubuntu16.04-onbuild\n\n# ==\u003e Specify requirements filename;  default = \"requirements.yml\"\n#ENV REQUIREMENTS  requirements.yml\n\n# ==\u003e Specify playbook filename;      default = \"playbook.yml\"\n#ENV PLAYBOOK      playbook.yml\n\n# ==\u003e Specify inventory filename;     default = \"/etc/ansible/hosts\"\n#ENV INVENTORY     inventory.ini\n\n# ==\u003e Executing Ansible (with a simple wrapper)...\nRUN ansible-playbook-wrapper\n```\n\nThird, `docker build .`\n\nDone!\n\nFor more advanced usage, the role in Ansible Galaxy [`williamyeh/nginx`](https://galaxy.ansible.com/williamyeh/nginx/) demonstrates how to perform a simple smoke test (*configuration needs test, too!*) on a variety of (*containerized*) Linux distributions on [CircleCI](https://circleci.com/)'s Ubuntu 12.04 and [Travis CI](https://travis-ci.org/)’s Ubuntu 14.04 worker instances.\n\n\n\n\n## Why yet another Ansible image for Docker?\n\nThere has been quite a few Ansible images for Docker (e.g., [search](https://hub.docker.com/search/?isAutomated=1\u0026isOfficial=0\u0026page=1\u0026pullCount=0\u0026q=ansible\u0026starCount=0) in the Docker Hub), so why reinvent the wheel?\n\nIn the beginning I used the [`ansible/ansible-docker-base`](https://github.com/ansible/ansible-docker-base) created by Ansible Inc. It worked well, but left some room for improvement:\n\n- *Base OS image* - It provides only `centos:centos7` and `ubuntu:14.04`.  Insufficent for me.\n\n- *Unnecessary dependencies* - It installed, at the very beginning of its Dockerfile, the `software-properties-common` package, which in turns installed some Python packages. I prefered to incorporate these stuff only when absolutely needed.\n\nTherefore, I built these Docker images on my own.\n\n**NOTE:** [`ansible/ansible-docker-base`](https://github.com/ansible/ansible-docker-base) announced in September 2015: “Ansible no longer maintains images in Dockerhub directly.”\n\n### Comparison: image size\n\n```\nREPOSITORY                    TAG                   VIRTUAL SIZE\n---------------------------   -------------------   ------------\nansible/centos7-ansible       stable                367.5 MB\nansible/ubuntu14.04-ansible   stable                286.6 MB\n\nwilliamyeh/ansible            alpine3-onbuild        66.4 MB\nwilliamyeh/ansible            centos6-onbuild       264.2 MB\nwilliamyeh/ansible            centos7-onbuild       275.3 MB\nwilliamyeh/ansible            debian7-onbuild       134.4 MB\nwilliamyeh/ansible            debian8-onbuild       178.3 MB\nwilliamyeh/ansible            ubuntu12.04-onbuild   181.9 MB\nwilliamyeh/ansible            ubuntu14.04-onbuild   238.3 MB\n```\n\n\n## Usage\n\nUsed mostly as a *base image* for configuring other software stack on some specified Linux distribution(s).\n\nTake Debian/Ubuntu/CentOS for example. To test an Ansible `playbook.yml` against a variety of Linux distributions, we may use [Vagrant](https://www.vagrantup.com/) as follows:\n\n```ruby\n# Vagrantfile\n\nVagrant.configure(2) do |config|\n\n    # ==\u003e Choose a Vagrant box to emulate Linux distribution...\n    config.vm.box = \"ubuntu/xenial64\"\n    #config.vm.box = \"ubuntu/trusty64\"\n    #config.vm.box = \"debian/stretch64\"\n    #config.vm.box = \"debian/jessie64\"\n    #config.vm.box = \"bento/centos-7.2\"\n    #config.vm.box = \"maier/alpine-3.3.1-x86_64\"\n\n\n    # ==\u003e Executing Ansible...\n    config.vm.provision \"ansible\" do |ansible|\n        ansible.playbook = \"playbook.yml\"\n    end\n\nend\n```\n\nVirtual machines can emulate a variety of Linux distributions with good quality, at the cost of runtime overhead.\n\n\nDocker to be a rescue. Now, with these **williamyeh/ansible** series, we may test an Ansible `playbook.yml` against a variety of Linux distributions as follows:\n\n\n```dockerfile\n# Dockerfile\n\n# ==\u003e Choose a base image to emulate Linux distribution...\nFROM williamyeh/ansible:ubuntu16.04\n#FROM williamyeh/ansible:ubuntu14.04\n#FROM williamyeh/ansible:debian9\n#FROM williamyeh/ansible:debian8\n#FROM williamyeh/ansible:centos7\n#FROM williamyeh/ansible:alpine3\n\n\n# ==\u003e Copying Ansible playbook...\nWORKDIR /tmp\nCOPY  .  /tmp\n\n# ==\u003e Creating inventory file...\nRUN echo localhost \u003e inventory\n\n# ==\u003e Executing Ansible...\nRUN ansible-playbook -i inventory playbook.yml \\\n      --connection=local --sudo\n```\n\nYou may also work with `onbuild` variants, which take care of many routine steps for you:\n\n```dockerfile\n# Dockerfile\n\n# ==\u003e Choose a base image to emulate Linux distribution...\nFROM williamyeh/ansible:ubuntu16.04-onbuild\n#FROM williamyeh/ansible:ubuntu14.04-onbuild\n#FROM williamyeh/ansible:debian9-onbuild\n#FROM williamyeh/ansible:debian8-onbuild\n#FROM williamyeh/ansible:centos7-onbuild\n#FROM williamyeh/ansible:alpine3-onbuild\n\n\n# ==\u003e Specify requirements filename;  default = \"requirements.yml\"\n#ENV REQUIREMENTS  requirements.yml\n\n# ==\u003e Specify playbook filename;      default = \"playbook.yml\"\n#ENV PLAYBOOK      playbook.yml\n\n# ==\u003e Specify inventory filename;     default = \"/etc/ansible/hosts\"\n#ENV INVENTORY     inventory.ini\n\n# ==\u003e Executing Ansible (with a simple wrapper)...\nRUN ansible-playbook-wrapper\n```\n\n\n\nWith Docker, we can test any Ansible playbook against any version of any Linux distribution without the help of Vagrant. More lightweight, and more portable across IaaS, PaaS, and even CaaS (Container as a Service) providers!\n\nIf better OS emulation (virtualization) isn't required, the Docker approach (containerization) should give you a more efficient Ansible experience.\n\n\n\n## License\n\nAuthor: William Yeh \u003cwilliam.pjyeh@gmail.com\u003e\n\nLicensed under the Apache License V2.0. See the [LICENSE file](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWilliam-Yeh%2Fdocker-ansible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWilliam-Yeh%2Fdocker-ansible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWilliam-Yeh%2Fdocker-ansible/lists"}