PR #60: Small syntax tweaks for better highlighting.

This commit is contained in:
Jeff Geerling 2015-12-13 14:06:12 -06:00
parent 42a51bc5af
commit 379953325c
4 changed files with 37 additions and 34 deletions

View file

@ -1,41 +1,40 @@
sudo: required sudo: required
env: env:
- > # CentOS 7.
container_id=$(mktemp) - container_id: $(mktemp)
distribution=centos distribution: centos
version=7 version: 7
init=/usr/lib/systemd/systemd init: /usr/lib/systemd/systemd
run_opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- > # Ubuntu 14.04.
container_id=$(mktemp) - container_id: $(mktemp)
distribution=ubuntu distribution: ubuntu
version=14.04 version: 14.04
init=/sbin/init init: /sbin/init
run_opts="" run_opts: ""
services: services:
- docker - docker
before_install: before_install:
- sudo apt-get update - sudo apt-get update
# Pull container # Pull container.
- sudo docker pull ${distribution}:${version} - "sudo docker pull ${distribution}:${version}"
# Customize container # Customize container.
- sudo docker build --rm=true --file=tests/Dockerfile.${distribution} --tag=${distribution}:ansible tests - "sudo docker build --rm=true --file=tests/Dockerfile.${distribution} --tag=${distribution}:ansible tests"
script: script:
# # Run container in detached state.
# Run test playbook
#
# 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}" - sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}:ansible "${init}" > "${container_id}"
# Syntax check # 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 - '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 test - '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 sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml
| grep -q 'changed=0.*failed=0' | grep -q 'changed=0.*failed=0'
@ -43,7 +42,4 @@ script:
|| (echo 'Idempotence test: fail' && exit 1) || (echo 'Idempotence test: fail' && exit 1)
# Clean up # Clean up
- sudo docker stop "$(cat ${container_id})" - 'sudo docker stop "$(cat ${container_id})"'
notifications:
email: false

View file

@ -1,4 +1,5 @@
FROM centos:7 FROM centos:7
# Install systemd -- See https://hub.docker.com/_/centos/ # Install systemd -- See https://hub.docker.com/_/centos/
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
RUN yum -y update; yum clean all; \ 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/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \ rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*; rm -f /lib/systemd/system/anaconda.target.wants/*;
# Install Ansible # Install Ansible
RUN yum -y install epel-release RUN yum -y install epel-release
RUN yum -y install git ansible sudo RUN yum -y install git ansible sudo
RUN yum clean all RUN yum clean all
# Disable requiretty # Disable requiretty
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
# Install Ansible inventory file # Install Ansible inventory file
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts 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"]

View file

@ -1,9 +1,10 @@
FROM ubuntu:14.04 FROM ubuntu:14.04
# Install Ansible # Install Ansible
RUN apt-get install -y software-properties-common git RUN apt-get install -y software-properties-common git
RUN apt-add-repository -y ppa:ansible/ansible RUN apt-add-repository -y ppa:ansible/ansible
RUN apt-get update RUN apt-get update
RUN apt-get install -y ansible RUN apt-get install -y ansible
# Install Ansible inventory file # Install Ansible inventory file
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

View file

@ -1,5 +1,6 @@
--- ---
- hosts: all - hosts: all
vars: vars:
apache_listen_port_ssl: 443 apache_listen_port_ssl: 443
apache_create_vhosts: true apache_create_vhosts: true
@ -7,5 +8,6 @@
apache_vhosts: apache_vhosts:
- servername: "example.com" - servername: "example.com"
documentroot: "/var/www/vhosts/example_com" documentroot: "/var/www/vhosts/example_com"
roles: roles:
- role_under_test - role_under_test