Skip to content

Commit

Permalink
Merge pull request #3 from mrlesmithjr/integrate-new-travis-ci-testing
Browse files Browse the repository at this point in the history
Integrate new travis ci testing
  • Loading branch information
mrlesmithjr authored Apr 30, 2018
2 parents 9008e93 + 71430d3 commit e67ac10
Show file tree
Hide file tree
Showing 17 changed files with 254 additions and 4 deletions.
59 changes: 59 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
language: python
python: "2.7"

# Use the new container infrastructure
sudo: required

services:
- docker

env:
# - distribution: centos
# init: /usr/lib/systemd/systemd
# version: 7
# - distribution: fedora
# init: /usr/lib/systemd/systemd
# version: 26
# - distribution: fedora
# init: /usr/lib/systemd/systemd
# version: 25
# - distribution: fedora
# init: /usr/lib/systemd/systemd
# version: 24
- distribution: ubuntu
init: /lib/systemd/systemd
version: bionic
- distribution: ubuntu
init: /lib/systemd/systemd
version: xenial
- distribution: ubuntu
init: /sbin/init
version: trusty
# - distribution: debian
# init: /lib/systemd/systemd
# version: stretch
# - distribution: debian
# init: /lib/systemd/systemd
# version: jessie

before_install:
- 'sudo docker pull ${distribution}:${version}'
- 'sudo docker build --no-cache --rm --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'

script:
- container_id=$(mktemp)
- role_name="ansible-nginx-load-balancer"
- 'sudo docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume="${PWD}":/etc/ansible/roles/${role_name}:ro ${distribution}-${version}:ansible ${init} > "${container_id}"'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-lint -c /.ansible-lint /etc/ansible/roles/${role_name}/tests/test.yml'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/${role_name}/tests/test.yml --syntax-check'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/${role_name}/tests/test.yml'
- >
sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/${role_name}/tests/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
- 'sudo docker rm -f "$(cat ${container_id})"'

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

An [Ansible](https://www.ansible.com) role to install/configure an [NGINX](https://nginx.org) load balancer for HTTP/HTTPS/TCP/UDP

## Build Status

[![Build Status](https://travis-ci.org/mrlesmithjr/ansible-nginx-load-balancer.svg?branch=master)](https://travis-ci.org/mrlesmithjr/ansible-nginx-load-balancer)

## Requirements

None
Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ galaxy_info:
platforms:
- name: Ubuntu
versions:
- bionic
- trusty
- xenial
- zesty
Expand Down
17 changes: 17 additions & 0 deletions setup_travis_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

TAR_FILE="v1.4.3.tar.gz"

# Prompt for Ansible role name
read -p "Enter the Ansible role name: " input

# Update .travis.yml with Ansible role name
sed -i '' "s/replace_role/${input}/g" ".travis.yml"

# Update tests/test.yml with Ansible role name
sed -i '' "s/replace_role/${input}/g" "tests/test.yml"

# Cleanup
if [ -f $TAR_FILE ]; then
rm $TAR_FILE
fi
2 changes: 2 additions & 0 deletions tasks/ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
-in {{nginx_load_balancer_ssl['csr_key_file'] }}
-out {{ nginx_load_balancer_ssl['public_key_file'] }}
become: true
tags:
- skip_ansible_lint
when: >
nginx_load_balancer_ssl['generate_keys'] and
(not nginx_load_balancer_ha or
Expand Down
1 change: 1 addition & 0 deletions tests/.ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
skip_list: []
27 changes: 27 additions & 0 deletions tests/Dockerfile.centos-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM centos:7
ENV container=docker

RUN yum -y install epel-release && \
yum -y install gmp-devel libffi-devel openssl-devel python-crypto \
python-devel python-pip python-setuptools python-virtualenv \
redhat-rpm-config && \
yum -y group install "Development Tools"

# Install systemd -- See https://hub.docker.com/_/centos/
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;

RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint

COPY .ansible-lint /

VOLUME ["/sys/fs/cgroup"]

CMD ["/usr/sbin/init"]
13 changes: 13 additions & 0 deletions tests/Dockerfile.debian-jessie
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM debian:jessie
ENV container=docker

RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv

RUN pip install --upgrade pip setuptools && \
pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint

COPY .ansible-lint /
12 changes: 12 additions & 0 deletions tests/Dockerfile.debian-stretch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM debian:stretch
ENV container=docker

RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv systemd

RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint

COPY .ansible-lint /
26 changes: 26 additions & 0 deletions tests/Dockerfile.fedora-24
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM fedora:24
ENV container=docker

RUN dnf -y install gmp-devel libffi-devel openssl-devel python-crypto \
python-devel python-dnf python-pip python-setuptools python-virtualenv \
redhat-rpm-config systemd && \
dnf -y group install "C Development Tools and Libraries"

# Install systemd -- See https://hub.docker.com/_/centos/
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;

RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint

COPY .ansible-lint /

VOLUME ["/sys/fs/cgroup"]

CMD ["/usr/sbin/init"]
26 changes: 26 additions & 0 deletions tests/Dockerfile.fedora-25
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM fedora:25
ENV container=docker

RUN dnf -y install gmp-devel libffi-devel openssl-devel python-crypto \
python-devel python-dnf python-pip python-setuptools python-virtualenv \
redhat-rpm-config systemd && \
dnf -y group install "C Development Tools and Libraries"

# Install systemd -- See https://hub.docker.com/_/centos/
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;

RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint

COPY .ansible-lint /

VOLUME ["/sys/fs/cgroup"]

CMD ["/usr/sbin/init"]
26 changes: 26 additions & 0 deletions tests/Dockerfile.fedora-26
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM fedora:26
ENV container=docker

RUN dnf -y install gmp-devel libffi-devel openssl-devel python-crypto \
python-devel python-dnf python-pip python-setuptools python-virtualenv \
redhat-rpm-config systemd && \
dnf -y group install "C Development Tools and Libraries"

# Install systemd -- See https://hub.docker.com/_/centos/
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;

RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint

COPY .ansible-lint /

VOLUME ["/sys/fs/cgroup"]

CMD ["/usr/sbin/init"]
12 changes: 12 additions & 0 deletions tests/Dockerfile.ubuntu-bionic
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:bionic
ENV container=docker

RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv systemd

RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint

COPY .ansible-lint /
13 changes: 13 additions & 0 deletions tests/Dockerfile.ubuntu-trusty
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:trusty
ENV container=docker

RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv

RUN pip install --upgrade pip setuptools && \
pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint

COPY .ansible-lint /
12 changes: 12 additions & 0 deletions tests/Dockerfile.ubuntu-xenial
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:xenial
ENV container=docker

RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv

RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint

COPY .ansible-lint /
1 change: 0 additions & 1 deletion tests/inventory
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
localhost

6 changes: 3 additions & 3 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- hosts: localhost
remote_user: root
- hosts: localhost
connection: local
roles:
- ansible-nginx-load-balancer
- ansible-nginx-load-balancer

0 comments on commit e67ac10

Please sign in to comment.