diff --git a/.travis.yml b/.travis.yml index f67ce39..29fff60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,60 +2,48 @@ sudo: required env: - - distribution: centos - version: 6 - init: /sbin/init - run_opts: "" - SITE: source - - distribution: centos - version: 7 + - distro: centos7 init: /usr/lib/systemd/systemd run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" - SITE: source - - distribution: ubuntu - version: 14.04 - init: /sbin/init - run_opts: "" - SITE: source - - distribution: ubuntu - version: 12.04 - init: /sbin/init - run_opts: "" - SITE: source + - distro: ubuntu1604 + init: /lib/systemd/systemd + run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" services: - docker before_install: - # Pull container - - 'sudo docker pull ${distribution}:${version}' - # Customize container - - 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests' + # Pull container. + - 'sudo docker pull geerlingguy/docker-${distro}-ansible:latest' script: - container_id=$(mktemp) - # Run container in detached state - - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"' + # Run container in detached state. + - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"' # Install dependencies. - - 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install geerlingguy.php geerlingguy.repo-remi' + - 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml' # Ansible syntax check. - - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.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-${SITE}.yml' + - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' # Test role idempotence. + - idempotence=$(mktemp) + - sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence} - > - sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml + tail ${idempotence} | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) + # Run script to test if Xdebug is available and working. - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm php /etc/ansible/roles/role_under_test/tests/xdebug-test.php' - # Clean up +after_success: + # Clean up. - 'sudo docker stop "$(cat ${container_id})"' notifications: diff --git a/README.md b/README.md index 6fe8480..9c50ac1 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Available variables are listed below, along with default values (see `defaults/m Where Xdebug setup files will be downloaded and built. - php_xdebug_version: 2.4.0 + php_xdebug_version: 2.4.1 The version of Xdebug to be installed (see [Updates](https://xdebug.org/updates.php) for a current listing). @@ -74,4 +74,4 @@ MIT / BSD ## Author Information -This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/). +This role was created in 2014 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/defaults/main.yml b/defaults/main.yml index ecccbf1..baa9947 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,7 @@ --- workspace: /root -php_xdebug_version: 2.4.0 +php_xdebug_version: 2.4.1 php_xdebug_coverage_enable: 1 php_xdebug_default_enable: 1 diff --git a/tests/Dockerfile.centos-6 b/tests/Dockerfile.centos-6 deleted file mode 100644 index 7adc80e..0000000 --- a/tests/Dockerfile.centos-6 +++ /dev/null @@ -1,19 +0,0 @@ -FROM centos:6 - -# Install Ansible -RUN yum -y update; yum clean all; -RUN yum -y install epel-release -RUN yum update openssl -RUN yum -y install git python-setuptools gcc sudo libffi-devel python-devel openssl-devel -RUN yum clean all -RUN easy_install pip -RUN pip install ansible - -# Disable requiretty -RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers - -# Install Ansible inventory file -RUN mkdir -p /etc/ansible -RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts - -CMD ["/usr/sbin/init"] diff --git a/tests/Dockerfile.centos-7 b/tests/Dockerfile.centos-7 deleted file mode 100644 index 7df59cd..0000000 --- a/tests/Dockerfile.centos-7 +++ /dev/null @@ -1,29 +0,0 @@ -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; \ -(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/*; - -# Install Ansible -RUN yum -y install git python-setuptools gcc sudo libffi-devel python-devel openssl-devel -RUN yum clean all -RUN easy_install pip -RUN pip install ansible - -# Disable requiretty -RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers - -# Install Ansible inventory file -RUN mkdir -p /etc/ansible -RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts - -VOLUME ["/sys/fs/cgroup"] -CMD ["/usr/sbin/init"] diff --git a/tests/Dockerfile.ubuntu-12.04 b/tests/Dockerfile.ubuntu-12.04 deleted file mode 100644 index d0c130c..0000000 --- a/tests/Dockerfile.ubuntu-12.04 +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:12.04 -RUN apt-get update - -# Install Ansible -RUN apt-get install -y software-properties-common python-software-properties 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 diff --git a/tests/Dockerfile.ubuntu-14.04 b/tests/Dockerfile.ubuntu-14.04 deleted file mode 100644 index ca33287..0000000 --- a/tests/Dockerfile.ubuntu-14.04 +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:14.04 -RUN apt-get update - -# 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 diff --git a/tests/inventory b/tests/inventory deleted file mode 100644 index 2fbb50c..0000000 --- a/tests/inventory +++ /dev/null @@ -1 +0,0 @@ -localhost diff --git a/tests/requirements.yml b/tests/requirements.yml new file mode 100644 index 0000000..80e765f --- /dev/null +++ b/tests/requirements.yml @@ -0,0 +1,3 @@ +--- +- src: geerlingguy.repo-remi +- src: geerlingguy.php diff --git a/tests/test-source.yml b/tests/test.yml similarity index 50% rename from tests/test-source.yml rename to tests/test.yml index 9f1e024..e9a8199 100644 --- a/tests/test-source.yml +++ b/tests/test.yml @@ -3,19 +3,15 @@ vars: php_enable_webserver: false - php_version: 5.6 - php_enablerepo: "remi,remi-php56" + php_enablerepo: "remi,remi-php70" pre_tasks: - name: Ensure build dependencies are installed (RedHat). yum: name=which state=present when: ansible_os_family == 'RedHat' - - name: Add repository for PHP 5.6. - apt_repository: repo='ppa:ondrej/php5-5.6' - when: ansible_os_family == 'Debian' - roles: - - { role: geerlingguy.repo-remi, when: ansible_os_family == 'RedHat' } + - role: geerlingguy.repo-remi + when: ansible_os_family == 'RedHat' - geerlingguy.php - role_under_test