Manage many configurations
parent
41a5575627
commit
60a368f3e1
11
.travis.yml
11
.travis.yml
|
@ -1,15 +1,20 @@
|
||||||
env:
|
matrix:
|
||||||
- PLATFORM=debian-jessie
|
include:
|
||||||
|
- env: PLATFORM=debian-jessie ORIGIN=debian NGINX_PHP56=true NGINX_PHP70=false NGINX_BACKPORTS=false DOTDEB=false
|
||||||
|
- env: PLATFORM=debian-jessie ORIGIN=backports NGINX_PHP56=true NGINX_PHP70=false NGINX_BACKPORTS=true DOTDEB=false
|
||||||
|
- env: PLATFORM=debian-jessie ORIGIN=dotdeb NGINX_PHP56=true NGINX_PHP70=true NGINX_BACKPORTS=false DOTDEB=true
|
||||||
|
|
||||||
sudo: required
|
sudo: required
|
||||||
|
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
language: python
|
language: python
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- docker build -f tests/$PLATFORM.Dockerfile -t test-$PLATFORM . && docker run --name $PLATFORM test-$PLATFORM
|
- docker build -f tests/$PLATFORM.Dockerfile -t test-$PLATFORM . && docker run -e "DOTDEB=$DOTDEB" -e "NGINX_PHP56=$NGINX_PHP56" -e "NGINX_PHP70=$NGINX_PHP70" -e "NGINX_BACKPORTS=$NGINX_BACKPORTS" --name $PLATFORM test-$PLATFORM
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
|
|
||||||
vms_debian = [
|
vms_debian = [
|
||||||
[ "debian-jessie", "debian/jessie64" ],
|
{ :name => "debian-jessie", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": false }},
|
||||||
[ "debian-stretch", "sharlak/debian_stretch_64" ]
|
{ :name => "debian-jessie-backports", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": false, "dotdeb": false, "nginx_backports": true }},
|
||||||
|
{ :name => "debian-jessie-dotdeb", :box => "debian/jessie64", :vars => { "nginx_php56": true, "nginx_php70": true, "dotdeb": true, "nginx_backports": false }},
|
||||||
|
{ :name => "debian-stretch", :box => "sharlak/debian_stretch_64", :vars => { "nginx_php56": false, "nginx_php70": true, "dotdeb": false, "nginx_backports": false }}
|
||||||
]
|
]
|
||||||
|
|
||||||
vms_freebsd = [
|
vms_freebsd = [
|
||||||
[ "freebsd-10.2", "freebsd/FreeBSD-10.2-STABLE" ]
|
{ :name => "freebsd-10.2", :box => "freebsd/FreeBSD-10.2-STABLE" }
|
||||||
]
|
]
|
||||||
|
|
||||||
config.vm.provider "virtualbox" do |v|
|
config.vm.provider "virtualbox" do |v|
|
||||||
|
@ -19,22 +21,22 @@ Vagrant.configure("2") do |config|
|
||||||
v.memory = 256
|
v.memory = 256
|
||||||
end
|
end
|
||||||
|
|
||||||
vms_debian.each do |vm|
|
vms_debian.each do |opts|
|
||||||
config.vm.define vm[0] do |m|
|
config.vm.define opts[:name] do |m|
|
||||||
m.vm.box = vm[1]
|
m.vm.box = opts[:box]
|
||||||
m.vm.network "private_network", type: "dhcp"
|
m.vm.network "private_network", type: "dhcp"
|
||||||
m.vm.provision "ansible" do |ansible|
|
m.vm.provision "ansible" do |ansible|
|
||||||
ansible.playbook = "tests/test.yml"
|
ansible.playbook = "tests/test.yml"
|
||||||
ansible.groups = { "test" => [ vm[0] ] }
|
|
||||||
ansible.verbose = 'vv'
|
ansible.verbose = 'vv'
|
||||||
ansible.sudo = true
|
ansible.sudo = true
|
||||||
|
ansible.extra_vars = opts[:vars]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# See: https://forums.freebsd.org/threads/52717/
|
# See: https://forums.freebsd.org/threads/52717/
|
||||||
vms_freebsd.each do |vm|
|
vms_freebsd.each do |opts|
|
||||||
config.vm.define vm[0] do |m|
|
config.vm.define opts[:name] do |m|
|
||||||
m.vm.box = vm[1]
|
m.vm.box = opts[:box]
|
||||||
m.vm.network "private_network", type: "dhcp"
|
m.vm.network "private_network", type: "dhcp"
|
||||||
m.vm.guest = :freebsd
|
m.vm.guest = :freebsd
|
||||||
m.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
|
m.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
|
||||||
|
@ -43,7 +45,6 @@ Vagrant.configure("2") do |config|
|
||||||
m.vm.provision "shell", inline: "pkg install -y python bash"
|
m.vm.provision "shell", inline: "pkg install -y python bash"
|
||||||
m.vm.provision "ansible" do |ansible|
|
m.vm.provision "ansible" do |ansible|
|
||||||
ansible.playbook = "tests/test.yml"
|
ansible.playbook = "tests/test.yml"
|
||||||
ansible.groups = { "test" => [ vm[0] ] }
|
|
||||||
ansible.verbose = 'vv'
|
ansible.verbose = 'vv'
|
||||||
ansible.sudo = true
|
ansible.sudo = true
|
||||||
ansible.extra_vars = {
|
ansible.extra_vars = {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{% extends "_base.j2" %}
|
{% extends "_base.j2" %}
|
||||||
|
|
||||||
{% macro phpv(version) %}
|
{% macro phpv(version) %}
|
||||||
{% if version == 56 or version == "5.6" %}
|
{% if version == 56 or version == "56" or version == "5.6" %}
|
||||||
{{ nginx_upstream_php56 -}}
|
{{ nginx_upstream_php56 -}}
|
||||||
{% elif version == 70 or version == "7.0" %}
|
{% elif version == 70 or version == "70" or version == "7.0" %}
|
||||||
{{ nginx_upstream_php70 -}}
|
{{ nginx_upstream_php70 -}}
|
||||||
{% else %}
|
{% else %}
|
||||||
{# Hack... define another upstream #}
|
{# Hack... define another upstream #}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM williamyeh/ansible:debian8-onbuild
|
FROM williamyeh/ansible:debian8-onbuild
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
CMD ["sh", "tests/test.sh"]
|
CMD ["sh", "tests/travis.sh"]
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
copy: >
|
copy: >
|
||||||
content="Package: *\nPin: release o=packages.dotdeb.org\nPin-Priority: 100"
|
content="Package: *\nPin: release o=packages.dotdeb.org\nPin-Priority: 100"
|
||||||
dest=/etc/apt/preferences
|
dest=/etc/apt/preferences
|
||||||
when: ansible_distribution_release == 'jessie'
|
when: ansible_distribution_release == 'jessie' and dotdeb
|
||||||
|
|
||||||
- name: APT | Install needed packages
|
- name: APT | Install needed packages
|
||||||
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
|
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
|
||||||
|
@ -20,17 +20,28 @@
|
||||||
- curl
|
- curl
|
||||||
- fcgiwrap
|
- fcgiwrap
|
||||||
- nghttp2
|
- nghttp2
|
||||||
- php5-fpm
|
|
||||||
- php5-sqlite
|
|
||||||
- php7.0-fpm
|
|
||||||
- php7.0-sqlite3
|
|
||||||
- strace
|
- strace
|
||||||
- vim
|
- vim
|
||||||
|
|
||||||
- name: SERVICE | Force start services
|
- name: APT | Install PHP5.6
|
||||||
service: name={{ item }} state=started
|
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
|
||||||
register: sf
|
|
||||||
with_items:
|
with_items:
|
||||||
- php5-fpm
|
- php5-fpm
|
||||||
|
- php5-sqlite
|
||||||
|
when: nginx_php56
|
||||||
|
|
||||||
|
- name: APT | Install PHP7
|
||||||
|
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
|
||||||
|
with_items:
|
||||||
- php7.0-fpm
|
- php7.0-fpm
|
||||||
- fcgiwrap
|
- php7.0-sqlite3
|
||||||
|
when: nginx_php70
|
||||||
|
|
||||||
|
- name: SERVICE | Force start services
|
||||||
|
service: name={{ item.name }} state=started
|
||||||
|
register: sf
|
||||||
|
with_items:
|
||||||
|
- { name: 'php5-fpm', cond: "{{ nginx_php56 }}" }
|
||||||
|
- { name: 'php7.0-fpm', cond: "{{ nginx_php70 }}" }
|
||||||
|
- { name: 'fcgiwrap', cond: true }
|
||||||
|
when: "{{ item.cond }}"
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
- hosts: all
|
- hosts: all
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
|
- debug: var=dotdeb
|
||||||
|
- debug: var=nginx_php56
|
||||||
|
- debug: var=nginx_php70
|
||||||
|
- debug: var=nginx_backports
|
||||||
- name: INCLUDE | Pre_tasks related to OS version
|
- name: INCLUDE | Pre_tasks related to OS version
|
||||||
include: "includes/pre_{{ ansible_distribution }}.yml"
|
include: "includes/pre_{{ ansible_distribution }}.yml"
|
||||||
- name: FILE | Create an internal SSL dir
|
- name: FILE | Create an internal SSL dir
|
||||||
|
@ -16,9 +20,6 @@
|
||||||
# Role vars
|
# Role vars
|
||||||
nginx_worker_processes: 1 # Ansible+FreeBSD can't detect CPU number
|
nginx_worker_processes: 1 # Ansible+FreeBSD can't detect CPU number
|
||||||
nginx_apt_package: 'nginx-extras'
|
nginx_apt_package: 'nginx-extras'
|
||||||
nginx_backports: true
|
|
||||||
nginx_php56: true
|
|
||||||
nginx_php70: true
|
|
||||||
nginx_dyn_modules: ['http_geoip']
|
nginx_dyn_modules: ['http_geoip']
|
||||||
nginx_upstreams:
|
nginx_upstreams:
|
||||||
- name: 'test'
|
- name: 'test'
|
||||||
|
@ -155,7 +156,7 @@
|
||||||
'/':
|
'/':
|
||||||
- 'alias /var/tmp;'
|
- 'alias /var/tmp;'
|
||||||
- name: 'test-php.local'
|
- name: 'test-php.local'
|
||||||
php_version: 70
|
php_version: "{{ '7.0' if nginx_php70 else '5.6' }}"
|
||||||
upstream_params:
|
upstream_params:
|
||||||
- 'fastcgi_param FOO bar;'
|
- 'fastcgi_param FOO bar;'
|
||||||
redirect_from:
|
redirect_from:
|
||||||
|
@ -246,19 +247,13 @@
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
# PHP
|
# PHP
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
- name: -- VERIFY PHP VHOSTS --
|
|
||||||
command: "curl -H 'Host: {{ item }}' http://127.0.0.1/"
|
|
||||||
register: p
|
|
||||||
changed_when: false
|
|
||||||
failed_when: p.stdout.find('PHP Version') == -1
|
|
||||||
with_items: ['test-php.local', 'test-php-index.local']
|
|
||||||
|
|
||||||
- name: -- VERIFY PHP5 VHOSTS (implicit default) --
|
- name: -- VERIFY PHP5 VHOSTS (implicit default) --
|
||||||
command: "curl -H 'Host: {{ item }}' http://127.0.0.1/"
|
command: "curl -H 'Host: {{ item }}' http://127.0.0.1/"
|
||||||
register: p
|
register: p
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: p.stdout.find('PHP Version 5') == -1
|
failed_when: p.stdout.find('PHP Version 5') == -1
|
||||||
with_items: ['test-php-index.local']
|
with_items: ['test-php-index.local']
|
||||||
|
when: nginx_php56
|
||||||
|
|
||||||
- name: -- VERIFY PHP7 VHOSTS --
|
- name: -- VERIFY PHP7 VHOSTS --
|
||||||
command: "curl -H 'Host: {{ item }}' http://127.0.0.1/"
|
command: "curl -H 'Host: {{ item }}' http://127.0.0.1/"
|
||||||
|
@ -266,6 +261,7 @@
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: p.stdout.find('PHP Version 7') == -1
|
failed_when: p.stdout.find('PHP Version 7') == -1
|
||||||
with_items: ['test-php.local']
|
with_items: ['test-php.local']
|
||||||
|
when: nginx_php70
|
||||||
|
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
# Basic Auth
|
# Basic Auth
|
||||||
|
|
|
@ -5,16 +5,21 @@
|
||||||
DIR=$( dirname $0 )
|
DIR=$( dirname $0 )
|
||||||
PLAYBOOK="$DIR/test.yml"
|
PLAYBOOK="$DIR/test.yml"
|
||||||
|
|
||||||
|
|
||||||
set -ev
|
set -ev
|
||||||
|
|
||||||
|
ANSIBLE_VARS="{ nginx_php56: $NGINX_PHP56, nginx_php70: $NGINX_PHP70, nginx_backports: $NGINX_BACKPORTS, dotdeb: $DOTDEB }"
|
||||||
|
|
||||||
|
echo $ANSIBLE_VARS
|
||||||
|
|
||||||
# Check syntax
|
# Check syntax
|
||||||
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
|
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
|
||||||
|
|
||||||
# Check role
|
# Check role
|
||||||
ansible-playbook -i localhost, -c local --sudo -vv $PLAYBOOK
|
ansible-playbook -i localhost, -c local -e "$ANSIBLE_VARS" --sudo -vv $PLAYBOOK
|
||||||
|
|
||||||
# Check indempotence
|
# Check indempotence
|
||||||
ansible-playbook -i localhost, -c local --sudo -vv $PLAYBOOK \
|
ansible-playbook -i localhost, -c local -e "$ANSIBLE_VARS" --sudo -vv $PLAYBOOK \
|
||||||
| grep -q 'changed=0.*failed=0' \
|
| grep -q 'changed=0.*failed=0' \
|
||||||
&& (echo 'Idempotence test: pass' && exit 0) \
|
&& (echo 'Idempotence test: pass' && exit 0) \
|
||||||
|| (echo 'Idempotence test: fail' && exit 1)
|
|| (echo 'Idempotence test: fail' && exit 1)
|
Loading…
Reference in New Issue