New PHP management

- New versions (7.x)
- PHP upstream name
- Sites can use : default PHP version, select first one by PHP version,
  select by upstream name
- Add PHP filter plugin
This commit is contained in:
Emilien Mantel
2017-10-26 10:59:24 +02:00
parent 70283ddcc6
commit 463ce45105
15 changed files with 122 additions and 120 deletions

View File

@@ -4,6 +4,7 @@
apt_repository:
repo: 'deb http://httpredir.debian.org/debian {{ ansible_distribution_release }}-backports main'
state: present
when: nginx_backports
- block:
@@ -22,7 +23,25 @@
content: "Package: *\nPin: release o=packages.dotdeb.org\nPin-Priority: 100"
dest: /etc/apt/preferences
when: ansible_distribution_release == 'jessie' and dotdeb
when: ansible_distribution_release == 'jessie' and dotdeb | default(false)
- block:
- name: APT | Install apt-transport-https
apt:
pkg: apt-transport-https
update_cache: yes
cache_valid_time: 3600
- name: APT_KEY | Install GPG key
apt_key:
url: 'https://packages.sury.org/php/apt.gpg'
- name: APT_REPOSITORY | Add APT repository
apt_repository:
repo: 'deb https://packages.sury.org/php {{ ansible_distribution_release }} main'
when: sury | default(false)
- name: APT | Install needed packages
apt:
@@ -37,35 +56,21 @@
- strace
- vim
- name: APT | Install PHP5.6
- name: APT | Install PHP
apt:
pkg: "{{ item }}"
pkg: "{{ item.version | php_fpm_package }}"
update_cache: yes
cache_valid_time: 3600
state: present
with_items:
- php5-fpm
- php5-sqlite
when: nginx_php56
with_items: "{{ nginx_php }}"
- name: APT | Install PHP7
apt:
pkg: "{{ item }}"
update_cache: yes
cache_valid_time: 3600
state: present
with_items:
- php7.0-fpm
- php7.0-sqlite3
when: nginx_php70
- name: SERVICE | Force start services
- name: SERVICE | Force start fcgiwrap
service:
name: "{{ item.name }}"
name: "fcgiwrap"
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
- name: SERVICE | Force start PHP
service:
name: "{{ item.version | php_fpm_service }}"
state: started
with_items: "{{ nginx_php }}"

View File

@@ -4,10 +4,11 @@
set_fact:
nginx_pkgng_package: 'nginx-devel'
nginx_user: 'www'
nginx_php70: false
nginx_php56_sockets:
- host: '127.0.0.1'
port: 9000
nginx_php:
- version: '5.6'
sockets:
- host: '127.0.0.1'
port: 9000
- name: PKGNG | Install needed packages
pkgng:

View File

@@ -2,10 +2,6 @@
- hosts: all
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
include: "includes/pre_{{ ansible_distribution }}.yml"
- name: FILE | Create an internal SSL dir
@@ -171,7 +167,7 @@
- '/b'
- '/c'
- name: 'test-php.local'
php_version: "{{ '7.0' if nginx_php70 else '5.6' }}"
php_version: "{{ nginx_php.1.version if nginx_php.1 is defined else nginx_php.0.version }}"
upstream_params:
- 'fastcgi_param FOO bar;'
redirect_from:
@@ -296,21 +292,15 @@
# --------------------------------
# PHP
# --------------------------------
- name: -- VERIFY PHP5 SITES (implicit default) --
command: "curl -H 'Host: {{ item }}' http://127.0.0.1/"
- name: -- VERIFY PHP SITES --
command: "curl -H 'Host: {{ item.name }}' http://127.0.0.1/"
register: p
with_items: "{{ nginx_sites }}"
when: >
item.template is defined and
(item.template == '_php' or item.template == '_php_index')
changed_when: false
failed_when: p.stdout.find('PHP Version 5') == -1
with_items: ['test-php-index.local']
when: nginx_php56
- name: -- VERIFY PHP7 SITES --
command: "curl -H 'Host: {{ item }}' http://127.0.0.1/"
register: p
changed_when: false
failed_when: p.stdout.find('PHP Version 7') == -1
with_items: ['test-php.local']
when: nginx_php70
failed_when: p.stdout.find('PHP Version ' + item.php_version if 'php_version' in item else nginx_php.0.version) == -1
# --------------------------------
# Basic Auth
@@ -377,7 +367,7 @@
register: nagios_cgi
failed_when: nagios_cgi.stdout.find('Nagios Event Summary') == -1
when: ansible_distribution_major_version | version_compare('9', 'lt')
when: ansible_distribution_major_version | version_compare('9', 'lt')
# --------------------------------
# Owncloud