Compat Ansible 2.5+

pull/12/head
Emilien Mantel 2019-01-28 14:46:58 +01:00
parent 6c3aa5443a
commit e45df940cd
8 changed files with 92 additions and 56 deletions

View File

@ -1,46 +1,25 @@
env: env:
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.0,<2.1'
- PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.0,<2.1'
- PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.0,<2.1'
- PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.0,<2.1'
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.1,<2.2'
- PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.1,<2.2'
- PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.1,<2.2'
- PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.1,<2.2'
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.5,<2.6' - PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.5,<2.6' - PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.5,<2.6' - PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.5,<2.6' - PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.6,<2.7' - PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.6,<2.7' - PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.6,<2.7' - PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.6,<2.7' - PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.0,<2.1'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.1,<2.2'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.6,<2.7' - PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.0,<2.1'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.1,<2.2'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.2,<2.3'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.6,<2.7' - PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-debian-stretch-php71' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-debian-stretch-php72' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-debian-stretch-php73' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.7,<2.8'
sudo: required sudo: required

View File

@ -5,3 +5,10 @@
name: '{{ php_fpm_service }}' name: '{{ php_fpm_service }}'
state: restarted state: restarted
when: php_install_fpm when: php_install_fpm
notify: docker restart php-fpm
- name: docker restart php-fpm
command: 'service {{ php_fpm_service }} restart'
args:
warn: false
when: ansible_virtualization_type == 'docker'

View File

@ -1,10 +1,10 @@
--- ---
galaxy_info: galaxy_info:
author: Emilien Mantel author: Emilien Mantel
description: Install and configure PHP 7.0/7.1/7.2 (+ FPM is wanted) description: Install and configure PHP 7.0/7.1/7.2/7.3
company: company:
license: GPLv2 license: GPLv2
min_ansible_version: 2.0 min_ansible_version: 2.5
platforms: platforms:
- name: Debian - name: Debian
versions: versions:

View File

@ -18,12 +18,12 @@
regexp: '^;?{{ item.key }}' regexp: '^;?{{ item.key }}'
line: '{{ item.key }} = {{ item.value }}' line: '{{ item.key }} = {{ item.value }}'
create: yes create: yes
with_dict: "{{ php_ini | combine(php_ini_fpm) }}" loop: "{{ php_ini | combine(php_ini_fpm) | dict2items }}"
notify: restart php-fpm notify: restart php-fpm
- name: TEMPLATE | Deploy pool configuration - name: TEMPLATE | Deploy pool configuration
template: template:
src: etc/__php__/fpm/pool.d/pool.conf.j2 src: etc/__php__/fpm/pool.d/pool.conf.j2
dest: '{{ php_fpm_pool_dir }}/{{ item.pool_name }}.conf' dest: '{{ php_fpm_pool_dir }}/{{ item.pool_name }}.conf'
with_items: "{{ php_fpm_poold }}" loop: "{{ php_fpm_poold }}"
notify: restart php-fpm notify: restart php-fpm

View File

@ -16,18 +16,14 @@
state: present state: present
update_cache: yes update_cache: yes
cache_valid_time: 3600 cache_valid_time: 3600
with_flattened: loop: "{{ php_packages + php_extra_packages | flatten }}"
- "{{ php_packages }}"
- "{{ php_extra_packages }}"
notify: restart php-fpm notify: restart php-fpm
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- name: PKGNG | Install PHP packages - name: PKGNG | Install PHP packages
pkgng: pkgng:
name: "{{ item }}" name: "{{ item }}"
with_flattened: loop: "{{ php_packages + php_extra_packages | flatten }}"
- "{{ php_packages }}"
- "{{ php_extra_packages }}"
notify: restart php-fpm notify: restart php-fpm
when: ansible_os_family == 'FreeBSD' when: ansible_os_family == 'FreeBSD'
@ -39,10 +35,34 @@
dest: '{{ php_cli_ini }}' dest: '{{ php_cli_ini }}'
regexp: '^;?{{ item.key }}' regexp: '^;?{{ item.key }}'
line: '{{ item.key }} = {{ item.value }}' line: '{{ item.key }} = {{ item.value }}'
with_dict: "{{ php_ini | combine(php_ini_cli) }}" loop: "{{ php_ini | combine(php_ini_cli) | dict2items }}"
- name: INCLUDE | Xdebug - name: INCLUDE | Xdebug
include: xdebug.yml include: xdebug.yml
- name: APT | Install and configure opcache - name: APT | Install and configure opcache
include: opcache.yml include: opcache.yml
- name: SERVICE | Ensure PHP-FPM is started
service:
name: '{{ php_fpm_service }}'
state: started
when: php_install_fpm and ansible_virtualization_type != 'docker'
- block:
- name: COMMAND | Check if PHP-FPM is started (Docker)
command: 'service {{ php_fpm_service }} status'
args:
warn: false
register: dps
changed_when: false
failed_when: false
- name: COMMAND | Ensure PHP-FPM is started (Docker)
command: 'service {{ php_fpm_service }} start'
args:
warn: false
when: dps.stdout.find('is not running') != -1
when: php_install_fpm and ansible_virtualization_type == 'docker'

View File

@ -6,10 +6,11 @@
- name: APT | Install packages - name: APT | Install packages
apt: apt:
pkg: "{{ item }}" pkg: "{{ p }}"
update_cache: yes update_cache: yes
cache_valid_time: 3600 cache_valid_time: 3600
with_items: vars:
p:
- apt-transport-https - apt-transport-https
- ca-certificates - ca-certificates
- curl - curl
@ -19,5 +20,5 @@
- name: INCLUDE | Sury - name: INCLUDE | Sury
include: Debian/sury.yml include: Debian/sury.yml
when: > when: >
ansible_distribution_major_version | version_compare(9, 'eq') and ansible_distribution_major_version is version(9, 'eq') and
php_version | version_compare('7.1', 'ge') php_version is version('7.1', 'ge')

View File

@ -7,7 +7,4 @@
- name: PKGNG | Install packages - name: PKGNG | Install packages
pkgng: pkgng:
name: "{{ item }}" name: ['curl', 'nginx']
with_items:
- curl
- nginx

View File

@ -48,12 +48,44 @@
dest: "{{ __nginx_conf | dirname }}/fastcgi.conf" dest: "{{ __nginx_conf | dirname }}/fastcgi.conf"
notify: reload nginx notify: reload nginx
- name: SERVICE | Ensure nginx is started
service:
name: nginx
state: started
when: ansible_virtualization_type != 'docker'
- block:
- name: COMMAND | Docker nginx status
command: service nginx status
args:
warn: false
changed_when: false
failed_when: false
register: ngs
- name: COMMAND | Docker start nginx
command: service nginx start
args:
warn: false
when: ngs.stdout.find('nginx is not running') != -1
when: ansible_virtualization_type == 'docker'
handlers: handlers:
- name: reload nginx - name: reload nginx
service: service:
name: nginx name: nginx
state: reloaded state: reloaded
notify: docker reload nginx
- name: docker reload nginx
command: service nginx reload
args:
warn: false
notify: docker reload nginx
when: ansible_virtualization_type == 'docker'
roles: roles:
- ../../ - ../../