Skip to content

Commit

Permalink
First version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frzk committed Feb 2, 2018
1 parent 3b53500 commit ca91223
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 0 deletions.
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# How to Contribute

## Pull Requests

1. Fork the docker-ubuntu16.04-ansible repository
2. Create a new branch for each feature or improvement
3. Send a pull request from each feature branch to the **develop** branch

It is very important to separate new features or improvements into separate feature branches, and to send a
pull request for each branch. This allows me to review and pull in new features or improvements individually.

## Bug Reports

1. Create an issue [here](https://github.com/Frzk/docker-ubuntu16.04-ansible/issues)
2. Add the `bug` label to the issue
3. Please provide as many details as you can (environment, steps to reproduce, config file, ...)

## Feature Requests

Feature Requests are only for **NEW** features. For existing features, please make an Enhancement Request.

1. Create an issue [here](https://github.com/Frzk/docker-ubuntu16.04-ansible/issues)
2. Add the `feature-request` label to the issue
3. Please describe the feature in a detailed way, with examples and use cases

## Enhancement Requests

Enhancement Requests are only for **EXISTING** features. For a new feature, please make a Feature Request.

1. Create an issue [here](https://github.com/Frzk/docker-ubuntu16.04-ansible/issues)
2. Add the `enhancement` label to the issue
3. Describe your idea
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Build Ubuntu 16.04 (Xenial) image.

FROM ubuntu:16.04
LABEL maintainer="François KUBLER"

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
git \
python-pip \
systemd \
&& rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade setuptools \
&& pip install wheel \
&& pip install ansible

RUN mkdir -p /etc/ansible
ADD hosts /etc/ansible/

ENV ANSIBLE_FORCE_COLOR 1

ENTRYPOINT ["/lib/systemd/systemd"]
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Ubuntu 16.04 (Xenial) Ansible test image

![Build Status](https://img.shields.io/docker/build/kblr/ubuntu16.04-ansible.svg) ![Automated](https://img.shields.io/docker/automated/kblr/ubuntu16.04-ansible.svg) ![Pulls](https://img.shields.io/docker/pulls/kblr/ubuntu16.04-ansible.svg) ![Stars](https://img.shields.io/docker/stars/kblr/ubuntu16.04-ansible.svg)

Ubuntu 16.04 (Xenial) Docker image for Ansible role testing in Travis-CI.

> TL;DR: `docker pull kblr/ubuntu16.04-ansible`

## Overview

I use Docker in Travis-CI to test my Ansible roles on multiple OS.

This repo allows me to (automatically) build an Ubuntu 16.04 image from the provided `Dockerfile`. This image contains the needed tools to run Ansible and the tests.

The image is built by Docker Hub automatically each time one of the following happens:
- the upstream OS container is updated;
- a commit is made on the `master` branch of this repo.


## How-to use with Travis-CI

Simply tell Travis to pull the image from Docker Hub and run a container based on it.

Your `.travis.yml` file should look like this:

```yaml
sudo: required
language: bash
services:
- docker

before_install:
# Pull the image from Docker Hub:
- docker pull kblr/ubuntu16.04-ansible:latest

script:
# Run a container based on the previously pulled image:
- >
docker run
--name "${TRAVIS_COMMIT}.ubuntu16.04"
--detach
--privileged
--mount type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup,readonly
--mount type=bind,source="$(pwd)",target=/etc/ansible/roles/under_test,readonly
kblr/ubuntu16.04-ansible:latest
# Execute tests:
- >
docker exec "${TRAVIS_COMMIT}.ubuntu16.04"
ansible-playbook -v /etc/ansible/roles/under_test/tests/test/yml --syntax-check
- >
docker exec ...
after_script:
- docker rm -f "${TRAVIS_COMMIT}.ubuntu16.04"

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
```
## How-to use locally
If you ever need to build the image manually:
1. [Install Docker](https://docs.docker.com/engine/installation/)
2. `git clone` this repo
3. `cd` in the freshly cloned repo
4. Build the image using `docker build --no-cache --rm --tag="ubuntu16.04:ansible" .`
5. `cd` in your Ansible role directory
5. From there, run a container using `docker run --name [whatever] --detach --privileged --mount type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup,readonly --mount type=bind,source="$(pwd)",target=/etc/ansible/roles/under_test,readonly ubuntu16.04:ansible`


## Contributing

Code reviews, patches, comments, bug reports and feature requests are welcome. Please read the [Contributing Guide](CONTRIBUTING.md) for further details.
2 changes: 2 additions & 0 deletions hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[local]
localhost ansible_connection=local

0 comments on commit ca91223

Please sign in to comment.