mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2024-12-22 02:50:19 +01:00
PR #60: Small syntax tweaks for better highlighting.
This commit is contained in:
parent
42a51bc5af
commit
379953325c
4 changed files with 37 additions and 34 deletions
58
.travis.yml
58
.travis.yml
|
@ -1,49 +1,45 @@
|
|||
sudo: required
|
||||
|
||||
env:
|
||||
- >
|
||||
container_id=$(mktemp)
|
||||
distribution=centos
|
||||
version=7
|
||||
init=/usr/lib/systemd/systemd
|
||||
run_opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
- >
|
||||
container_id=$(mktemp)
|
||||
distribution=ubuntu
|
||||
version=14.04
|
||||
init=/sbin/init
|
||||
run_opts=""
|
||||
# CentOS 7.
|
||||
- container_id: $(mktemp)
|
||||
distribution: centos
|
||||
version: 7
|
||||
init: /usr/lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
# Ubuntu 14.04.
|
||||
- container_id: $(mktemp)
|
||||
distribution: ubuntu
|
||||
version: 14.04
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
# Pull container
|
||||
- sudo docker pull ${distribution}:${version}
|
||||
# Customize container
|
||||
- sudo docker build --rm=true --file=tests/Dockerfile.${distribution} --tag=${distribution}:ansible tests
|
||||
# Pull container.
|
||||
- "sudo docker pull ${distribution}:${version}"
|
||||
# Customize container.
|
||||
- "sudo docker build --rm=true --file=tests/Dockerfile.${distribution} --tag=${distribution}:ansible tests"
|
||||
|
||||
script:
|
||||
#
|
||||
# Run test playbook
|
||||
#
|
||||
|
||||
# Run container in detached state
|
||||
# Run container in detached state.
|
||||
- sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}:ansible "${init}" > "${container_id}"
|
||||
|
||||
# Syntax check
|
||||
- sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check
|
||||
# Test role
|
||||
- sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml
|
||||
# Idempotence test
|
||||
# Ansible syntax check.
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
|
||||
|
||||
# Test role.
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
|
||||
|
||||
# Test role idempotence.
|
||||
- >
|
||||
sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml
|
||||
| grep -q 'changed=0.*failed=0'
|
||||
&& (echo 'Idempotence test: pass' && exit 0)
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
|
||||
# Clean up
|
||||
- sudo docker stop "$(cat ${container_id})"
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
# Clean up
|
||||
- 'sudo docker stop "$(cat ${container_id})"'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
FROM centos:7
|
||||
|
||||
# Install systemd -- See https://hub.docker.com/_/centos/
|
||||
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
|
||||
RUN yum -y update; yum clean all; \
|
||||
|
@ -10,14 +11,17 @@ 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/*;
|
||||
|
||||
# Install Ansible
|
||||
RUN yum -y install epel-release
|
||||
RUN yum -y install git ansible sudo
|
||||
RUN yum clean all
|
||||
|
||||
# Disable requiretty
|
||||
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
|
||||
# Install Ansible inventory file
|
||||
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
|
||||
VOLUME [ "/sys/fs/cgroup" ]
|
||||
CMD ["/usr/sbin/init"]
|
||||
|
||||
VOLUME ["/sys/fs/cgroup"]
|
||||
CMD ["/usr/sbin/init"]
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
FROM ubuntu:14.04
|
||||
|
||||
# Install Ansible
|
||||
RUN apt-get install -y software-properties-common git
|
||||
RUN apt-add-repository -y ppa:ansible/ansible
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y ansible
|
||||
|
||||
# Install Ansible inventory file
|
||||
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
- hosts: all
|
||||
|
||||
vars:
|
||||
apache_listen_port_ssl: 443
|
||||
apache_create_vhosts: true
|
||||
|
@ -7,5 +8,6 @@
|
|||
apache_vhosts:
|
||||
- servername: "example.com"
|
||||
documentroot: "/var/www/vhosts/example_com"
|
||||
|
||||
roles:
|
||||
- role_under_test
|
||||
|
|
Loading…
Reference in a new issue