Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samdoran/docker-ubuntu14-ansible
A Docker container for testing Ansible roles
https://github.com/samdoran/docker-ubuntu14-ansible
ansible docker ubuntu
Last synced: 3 days ago
JSON representation
A Docker container for testing Ansible roles
- Host: GitHub
- URL: https://github.com/samdoran/docker-ubuntu14-ansible
- Owner: samdoran
- Created: 2016-09-20T16:02:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-01T15:21:10.000Z (over 4 years ago)
- Last Synced: 2024-11-01T09:14:29.757Z (about 2 months ago)
- Topics: ansible, docker, ubuntu
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ubuntu 14 Ansible Test Image #
[![Container Repository on Quay](https://quay.io/repository/samdoran/ubuntu14-ansible/status "Container Repository on Quay")](https://quay.io/repository/samdoran/ubuntu14-ansible)This is a container for testing Ansible roles with [Molecule](https://molecule.readthedocs.io/en/stable/). It includes the latest version of Ansible available on this platform and is rebuilt regularly. It can also be used if you need to run Ansible on a specific operating system.
Note that Molecule does not use the Ansible version installed in the container when running tests.
## Build ##
To build your own version of this container, run:
podman build -t ubuntu14-ansible -f Containerfile .
## Testing a role using Molecule ##
If you don't already have a role repository, you can initialize one using this [cookiecutter template](https://github.com/samdoran/cookiecutter-ansible-role).
`molecule init template --url https://github.com/samdoran/cookiecutter-ansible-role`
Then run `molecule test` to run the full test suite against the role.
Run `molecule converge` to run the role against the test container but leave it running. This allows you to connect to the container using `molecule login` or just test running your role multiple times against an existing container.
If you already have a role being testing using Molecule, add this to the `platforms` section of your `molecule.yml` to use this image:
```yaml
platforms:
- name: role-test
image: "samdoran/${MOLECULE_DISTRIBUTION:-ubuntu14}-ansible:latest"
command: ${MOLECULE_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: yes
pre_build_image: yes
```The important parts are `pre_build_image: yes` and the `image` name. Molecule allows you to use environment variables in the configuration file, which is very handy. This allows you to easily change the container that molecule uses for tests (among other things) simply by changing the enivorment variable.
```
env MOLECULE_DISTRIBUTION=debian9 molecule test
```