Merge branch 'php7'

Conflicts:
	tests/inventory
	tests/test.sh
This commit is contained in:
Emilien Mantel
2016-03-04 17:34:46 +01:00
28 changed files with 156 additions and 87 deletions

View File

@@ -1,5 +1,5 @@
FROM williamyeh/ansible:debian8-onbuild
RUN apt-get update
CMD ["sh", "tests/test.sh"]
CMD ["sh", "tests/test.sh", "5.6"]

View File

@@ -0,0 +1,5 @@
FROM williamyeh/ansible:debian8-onbuild
RUN apt-get update
CMD ["sh", "tests/test.sh", "7.0"]

View File

@@ -1,5 +0,0 @@
FROM williamyeh/ansible:debian7-onbuild
RUN apt-get update
CMD ["sh", "tests/test.sh"]

1
tests/group_vars/php-5.6 Normal file
View File

@@ -0,0 +1 @@
php_version: '5.6'

1
tests/group_vars/php-7.0 Normal file
View File

@@ -0,0 +1 @@
php_version: '7.0'

7
tests/inventory Normal file
View File

@@ -0,0 +1,7 @@
localhost
[php-5.6]
localhost
[php-7.0]
localhost

View File

@@ -4,17 +4,20 @@
DIR=$( dirname $0 )
PLAYBOOK="$DIR/test.yml"
ANSIBLE_ARG="localhost"
set -ev
ansible --version
# Check syntax
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
# Check role
ansible-playbook -i localhost, -c local --sudo -vv $PLAYBOOK
ansible-playbook -i localhost, -c local -e "php_version=$1" --become -vv $PLAYBOOK
# Check indempotence
ansible-playbook -i localhost, -c local --sudo -vv $PLAYBOOK \
ansible-playbook -i localhost, -c local -e "php_version=$1" --become -vv $PLAYBOOK \
| grep -q 'changed=0.*failed=0' \
&& (echo 'Idempotence test: pass' && exit 0) \
|| (echo 'Idempotence test: fail' && exit 1)

View File

@@ -4,9 +4,19 @@
vars:
vhost: 'test.local'
php_extra_packages:
- 'php5-memcached'
- '{{ php_apt_prefix }}recode'
php_install_xdebug: true
pre_tasks:
- name: APT | Install DotDeb key
apt_key: url='http://www.dotdeb.org/dotdeb.gpg' state=present
when: >
ansible_distribution_major_version | version_compare(8, 'eq') and
php_version | version_compare('7.0', 'ge')
- name: APT | Add Dotdeb repository for Jessie + PHP7
apt_repository: repo='deb http://packages.dotdeb.org jessie all' state=present
when: >
ansible_distribution_major_version | version_compare(8, 'eq') and
php_version | version_compare('7.0', 'ge')
- name: APT | Install nginx
apt: pkg=nginx state=present update_cache=yes cache_valid_time=3600
- name: SHELL | Get nginx version
@@ -17,10 +27,11 @@
when: nginx_version.stdout | version_compare('1.6', '<', true)
- set_fact: nginx_include="fastcgi.conf"
when: nginx_version.stdout | version_compare('1.6', '>=', true)
tasks:
- name: COPY | Vhost
copy: >
dest=/etc/nginx/sites-enabled/{{ vhost }}
content='server { server_name {{ vhost }}; root /var/www; location ~ \.php$ { include {{ nginx_include }}; fastcgi_pass unix:/var/run/php5-fpm.sock; } }'
content='server { server_name {{ vhost }}; root /var/www; location ~ \.php$ { include {{ nginx_include }}; fastcgi_pass unix:{{ php_default_fpm_sock }}; } }'
notify: reload nginx
handlers:
- name: reload nginx
@@ -31,10 +42,14 @@
- name: SHELL | Test php-cli
shell: php -i | grep '^PHP Version' | head -n 1
changed_when: false
register: p
failed_when: p.stdout == ''
- name: FILE | Create /var/www
file: dest=/var/www state=directory
- name: COPY | Add phpinfo
copy: dest=/var/www/phpinfo.php content='<?php phpinfo();'
- name: SHELL | Check vhost
shell: "curl -v -H 'Host: {{ vhost }}' http://127.0.0.1/phpinfo.php 2> /dev/null | grep h1 | grep -o 'PHP Version 5.*<' | sed -r 's/<//g'"
shell: "curl -v -H 'Host: {{ vhost }}' http://127.0.0.1/phpinfo.php 2> /dev/null | grep h1 | grep -o 'PHP Version [57].*<' | sed -r 's/<//g'"
changed_when: false
register: c
failed_when: c.stdout == ''