New release (#14)
* Manages Debian 11 * Migrate to new TravisCI version * Fix lint errors * Use FQCN builtins * Drop Ubuntu Xenial support (16.04)pull/17/head 2.6.0
parent
3209f6b010
commit
309824dabf
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
|
||||
# TODO: enable later
|
||||
enable_list:
|
||||
- fqcn-builtins
|
||||
|
||||
skip_list:
|
||||
- role-name
|
51
.travis.yml
51
.travis.yml
|
@ -1,33 +1,38 @@
|
|||
---
|
||||
|
||||
env:
|
||||
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- PLATFORM='docker-debian-buster-php73' 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.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-php74' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-buster-php73' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-buster-php74' 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'
|
||||
global:
|
||||
- VAGRANT_VERSION='2.2.18'
|
||||
jobs:
|
||||
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-stretch-php74' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-buster-php73' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-bullseye-php74' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-bullseye-php80' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-buster-php74' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
|
||||
sudo: required
|
||||
|
||||
dist: trusty
|
||||
os:
|
||||
- linux
|
||||
dist: focal
|
||||
|
||||
language: python
|
||||
python: 2.7
|
||||
python:
|
||||
- 3.8
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb
|
||||
- sudo dpkg -i vagrant_2.0.1_x86_64.deb
|
||||
- sudo apt-get -q update
|
||||
- sudo apt-get install -y yamllint
|
||||
- sudo wget -nv https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_x86_64.deb
|
||||
- sudo dpkg -i vagrant_${VAGRANT_VERSION}_x86_64.deb
|
||||
|
||||
install:
|
||||
- pip install "$ANSIBLE_VERSION"
|
||||
- sudo pip install "ansible-core$ANSIBLE_VERSION"
|
||||
- sudo pip install ansible-lint
|
||||
- ansible-galaxy collection install community.general
|
||||
|
||||
script:
|
||||
- VAGRANT_DEFAULT_PROVIDER=docker vagrant up $PLATFORM
|
||||
|
@ -37,6 +42,14 @@ script:
|
|||
&& (echo 'Idempotence test: pass' && exit 0)
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
- VAGRANT_DEFAULT_PROVIDER=docker vagrant status
|
||||
- >
|
||||
yamllint .
|
||||
&& (echo 'YAML lint test: pass' && exit 0)
|
||||
|| (echo 'YAML lint test: fail' && exit 1)
|
||||
- >
|
||||
ansible-lint -v tests/test.yml
|
||||
&& (echo 'Ansible lint test: pass' && exit 0)
|
||||
|| (echo 'Ansible lint test: fail' && exit 1)
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
line-length: disable
|
21
README.md
21
README.md
|
@ -1,18 +1,19 @@
|
|||
Ansible PHP (+FPM) role for Debian / Ubuntu / FreeBSD
|
||||
=====================================================
|
||||
|
||||
[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.php-blue.svg)](https://galaxy.ansible.com/HanXHX/php) [![Build Status](https://travis-ci.org/HanXHX/ansible-php.svg?branch=master)](https://travis-ci.org/HanXHX/ansible-php)
|
||||
[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.php-blue.svg)](https://galaxy.ansible.com/HanXHX/php) [![Build Status](https://app.travis-ci.com/HanXHX/ansible-php.svg?branch=master)](https://app.travis-ci.com/HanXHX/ansible-php)
|
||||
|
||||
Install PHP on Debian / Ubuntu / FreeBSD. Manage PHP-FPM, APCu, Opcache and Xdebug.
|
||||
|
||||
Managed OS / Versions
|
||||
---------------------
|
||||
|
||||
| OS | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 |
|
||||
|:---------------------:|:-------------------:|:--------------------------:|:--------------------------:|:-------------------------:|:--------------------------:
|
||||
| Debian Stretch (9) | :heavy_check_mark: | :heavy_check_mark: (Sury) | :heavy_check_mark: (Sury) | :heavy_check_mark: (Sury) | :heavy_check_mark: (Sury) |
|
||||
| Debian Buster (10) | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: (Sury) |
|
||||
| Ubuntu Xenial (16.04) | :heavy_check_mark: | :x: | :x: | :x: | :x: |
|
||||
On all Debian versions, you can install all PHP versions (from PHP 5.6 to 8.1 beta) by using [Sury's APT repository](https://deb.sury.org/).
|
||||
|
||||
Other cases:
|
||||
|
||||
| OS | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP >= 7.4 |
|
||||
|:---------------------:|:-------------------:|:--------------------:|:--------------------:|:--------------------:|:--------------------:
|
||||
| Ubuntu Bionic (18.04) | :x: | :x: | :heavy_check_mark: | :x: | :x: |
|
||||
| FreeBSD 11 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Need tests... |
|
||||
| FreeBSD 12 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Need tests... |
|
||||
|
@ -23,7 +24,9 @@ Links:
|
|||
Requirements
|
||||
------------
|
||||
|
||||
If you need PHP-FPM, you must install a webserver with FastCGI support. You can use my [nginx role](https://github.com/HanXHX/ansible-nginx).
|
||||
- Ansible >= 2.11
|
||||
- Collections: [community.general](https://galaxy.ansible.com/community/general)
|
||||
- If you need PHP-FPM, you must install a webserver with FastCGI support. You can use my [nginx role](https://github.com/HanXHX/ansible-nginx).
|
||||
|
||||
FreeBSD limitations
|
||||
-------------------
|
||||
|
@ -160,12 +163,12 @@ Example Playbook
|
|||
roles:
|
||||
- { role: HanXHX.php }
|
||||
|
||||
### Debian Stretch with PHP 7.2 CLI (no FPM)
|
||||
### Debian Bullseye with PHP 8.0 CLI (no FPM)
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: HanXHX.sury }
|
||||
- { role: HanXHX.php, php_version: '7.2', php_install_fpm: false }
|
||||
- { role: HanXHX.php, php_version: '8.0', php_install_fpm: false }
|
||||
|
||||
License
|
||||
-------
|
||||
|
|
|
@ -7,13 +7,11 @@ Vagrant.configure("2") do |config|
|
|||
|
||||
vms_debian = [
|
||||
{ :name => "debian-stretch-php70", :box => "debian/stretch64", :vars => { }},
|
||||
{ :name => "debian-stretch-php71", :box => "debian/stretch64", :vars => { "php_version": '7.1' }},
|
||||
{ :name => "debian-stretch-php72", :box => "debian/stretch64", :vars => { "php_version": '7.2' }},
|
||||
{ :name => "debian-stretch-php73", :box => "debian/stretch64", :vars => { "php_version": '7.3' }},
|
||||
{ :name => "debian-stretch-php74", :box => "debian/stretch64", :vars => { "php_version": '7.4' }},
|
||||
{ :name => "debian-buster-php73", :box => "debian/buster64", :vars => { }},
|
||||
{ :name => "debian-buster-php74", :box => "debian/buster64", :vars => { "php_version": '7.4' }},
|
||||
{ :name => "ubuntu-xenial-php70", :box => "ubuntu/xenial64", :vars => { }},
|
||||
{ :name => "debian-bullseye-php74", :box => "debian/bullseye64", :vars => { }},
|
||||
{ :name => "debian-bullseye-php80", :box => "debian/bullseye64", :vars => { "php_version": '8.0' }},
|
||||
{ :name => "ubuntu-bionic-php72", :box => "ubuntu/bionic64", :vars => { }},
|
||||
]
|
||||
|
||||
|
@ -24,13 +22,11 @@ Vagrant.configure("2") do |config|
|
|||
|
||||
conts = [
|
||||
{ :name => "docker-debian-stretch-php70", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { }},
|
||||
{ :name => "docker-debian-stretch-php71", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.1' }},
|
||||
{ :name => "docker-debian-stretch-php72", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.2' }},
|
||||
{ :name => "docker-debian-stretch-php73", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.3' }},
|
||||
{ :name => "docker-debian-stretch-php74", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.4' }},
|
||||
{ :name => "docker-debian-buster-php73", :docker => "hanxhx/vagrant-ansible:debian10", :vars => { }},
|
||||
{ :name => "docker-debian-buster-php74", :docker => "hanxhx/vagrant-ansible:debian10", :vars => { "php_version": '7.4' }},
|
||||
{ :name => "docker-ubuntu-xenial-php70", :docker => "hanxhx/vagrant-ansible:ubuntu16.04", :vars => { }},
|
||||
{ :name => "docker-debian-bullseye-php74", :docker => "hanxhx/vagrant-ansible:debian11", :vars => { }},
|
||||
{ :name => "docker-debian-bullseye-php80", :docker => "hanxhx/vagrant-ansible:debian11", :vars => { "php_version": '8.0' }},
|
||||
{ :name => "docker-ubuntu-bionic-php72", :docker => "hanxhx/vagrant-ansible:ubuntu18.04", :vars => { }},
|
||||
]
|
||||
|
||||
|
@ -43,7 +39,12 @@ Vagrant.configure("2") do |config|
|
|||
d.remains_running = true
|
||||
d.has_ssh = true
|
||||
end
|
||||
m.vm.provision "shell", inline: "apt-get update && apt-get install -y python python-apt"
|
||||
|
||||
if opts[:name].include? "bullseye"
|
||||
m.vm.provision "shell", inline: "[ -f '/root/first_provision' ] || (apt-get update -qq && apt-get -y dist-upgrade && touch /root/first_provision)"
|
||||
end
|
||||
|
||||
#m.vm.provision "shell", inline: "apt-get update && apt-get install -y python python-apt"
|
||||
m.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/test.yml"
|
||||
ansible.verbose = 'vv'
|
||||
|
@ -61,6 +62,11 @@ Vagrant.configure("2") do |config|
|
|||
v.memory = 256
|
||||
end
|
||||
m.vm.provision "shell", inline: "apt-get update && apt-get install -y ifupdown python"
|
||||
|
||||
if opts[:name].include? "bullseye"
|
||||
m.vm.provision "shell", inline: "[ -f '/root/first_provision' ] || (apt-get update -qq && apt-get -y dist-upgrade && touch /root/first_provision)"
|
||||
end
|
||||
|
||||
m.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/test.yml"
|
||||
ansible.verbose = 'vv'
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
---
|
||||
|
||||
- name: restart php-fpm
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: '{{ php_fpm_service }}'
|
||||
state: restarted
|
||||
when: php_install_fpm
|
||||
notify: docker restart php-fpm
|
||||
|
||||
- name: docker restart php-fpm
|
||||
command: 'service {{ php_fpm_service }} restart'
|
||||
ansible.builtin.command: 'service {{ php_fpm_service }} restart'
|
||||
args:
|
||||
warn: false
|
||||
when: ansible_virtualization_type == 'docker'
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
---
|
||||
galaxy_info:
|
||||
author: Emilien Mantel
|
||||
description: Install and configure PHP 7.0/7.1/7.2/7.3
|
||||
description: Install and configure PHP 7.0/7.1/7.2/7.3/7.4/8.0
|
||||
company:
|
||||
license: GPLv2
|
||||
min_ansible_version: 2.6
|
||||
min_ansible_version: 2.11
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- stretch
|
||||
- buster
|
||||
- bullseye
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- xenial
|
||||
- bionic
|
||||
- name: FreeBSD
|
||||
versions:
|
||||
|
@ -23,10 +23,10 @@ galaxy_info:
|
|||
- development
|
||||
- web
|
||||
- php
|
||||
- php-fpm
|
||||
- fpm
|
||||
- php7
|
||||
- php8
|
||||
- debian
|
||||
- ubuntu
|
||||
- freebsd
|
||||
dependencies: []
|
||||
|
||||
|
|
|
@ -1,35 +1,41 @@
|
|||
---
|
||||
|
||||
- name: APT | Install PHP-FPM for Debian based systems
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ php_fpm_service }}"
|
||||
state: "{{ 'present' if php_install_fpm else 'absent' }}"
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: SERVICE | Enable service on FreeBSD
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "{{ php_fpm_service }}"
|
||||
enabled: "{{ 'yes' if php_install_fpm else 'no' }}"
|
||||
enabled: "{{ 'true' if php_install_fpm else 'false' }}"
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- name: LINEINFILE | PHP configuration
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
dest: '{{ php_fpm_ini }}'
|
||||
regexp: '^;?{{ item.key }}'
|
||||
line: '{{ item.key }} = {{ item.value }}'
|
||||
create: yes
|
||||
create: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
loop: "{{ php_ini | combine(php_ini_fpm) | dict2items }}"
|
||||
notify: restart php-fpm
|
||||
|
||||
- name: TEMPLATE | Deploy pool configuration
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: etc/__php__/fpm/pool.d/pool.conf.j2
|
||||
dest: '{{ php_fpm_pool_dir }}/{{ item.name }}.conf'
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
loop: "{{ ansible_local.hanxhx_php.fpm_pool }}"
|
||||
notify: restart php-fpm
|
||||
|
||||
- name: FILE | Delete default pool if necessary
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ php_fpm_pool_dir }}/www.conf"
|
||||
state: absent
|
||||
when: '"www" not in (ansible_local.hanxhx_php.fpm_pool | map(attribute="name") | list) and php_autoremove_default_pool'
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
---
|
||||
|
||||
- name: INCLUDE_VARS | Related to OS family
|
||||
include_vars: "OS_Family_{{ ansible_os_family }}.yml"
|
||||
ansible.builtin.include_vars: "OS_Family_{{ ansible_os_family }}.yml"
|
||||
|
||||
- name: INCLUDE_VARS | Related to OS version
|
||||
include_vars: "{{ item }}"
|
||||
ansible.builtin.include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||
|
||||
- name: SET_FACT | Transform data
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
__php_fpm_full_pool: |
|
||||
[
|
||||
{% for p in php_fpm_poold %}
|
||||
|
@ -32,32 +32,37 @@
|
|||
]
|
||||
|
||||
- name: SET_FACT | To YAML
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
php_fpm_full_pool: "{{ __php_fpm_full_pool | from_yaml }}"
|
||||
|
||||
- name: FILE | Creates ansible facts.d
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /etc/ansible/facts.d
|
||||
state: directory
|
||||
recurse: yes
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: COPY | Manage facts
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{ \"fpm_pool\": {{ php_fpm_full_pool | to_nice_json }} }"
|
||||
dest: /etc/ansible/facts.d/hanxhx_php.fact
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
register: f
|
||||
|
||||
- name: SETUP | Gathers new facts
|
||||
setup:
|
||||
ansible.builtin.setup:
|
||||
when: f.changed
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: APT | Install PHP packages
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ pkgs }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
vars:
|
||||
pkgs: "{{ php_packages + php_extra_packages | flatten }}"
|
||||
|
@ -65,29 +70,29 @@
|
|||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: PKGNG | Install PHP packages
|
||||
pkgng:
|
||||
community.general.pkgng:
|
||||
name: "{{ php_packages + php_extra_packages | flatten | join(',') }}"
|
||||
notify: restart php-fpm
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- name: IMPORT_TASKS | PHP-FPM
|
||||
import_tasks: fpm.yml
|
||||
ansible.builtin.import_tasks: fpm.yml
|
||||
|
||||
- name: LINEINFILE | PHP CLI configuration
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
dest: '{{ php_cli_ini }}'
|
||||
regexp: '^;?{{ item.key }}'
|
||||
line: '{{ item.key }} = {{ item.value }}'
|
||||
loop: "{{ php_ini | combine(php_ini_cli) | dict2items }}"
|
||||
|
||||
- name: IMPORT_TASKS | Xdebug
|
||||
import_tasks: xdebug.yml
|
||||
ansible.builtin.import_tasks: xdebug.yml
|
||||
|
||||
- name: APT | Install and configure opcache
|
||||
import_tasks: opcache.yml
|
||||
ansible.builtin.import_tasks: opcache.yml
|
||||
|
||||
- name: SERVICE | Ensure PHP-FPM is started
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: '{{ php_fpm_service }}'
|
||||
state: started
|
||||
when: php_install_fpm and ansible_virtualization_type != 'docker'
|
||||
|
@ -95,7 +100,7 @@
|
|||
- block:
|
||||
|
||||
- name: COMMAND | Check if PHP-FPM is started (Docker)
|
||||
command: 'service {{ php_fpm_service }} status'
|
||||
ansible.builtin.command: 'service {{ php_fpm_service }} status'
|
||||
args:
|
||||
warn: false
|
||||
register: dps
|
||||
|
@ -103,7 +108,7 @@
|
|||
failed_when: false
|
||||
|
||||
- name: COMMAND | Ensure PHP-FPM is started (Docker)
|
||||
command: 'service {{ php_fpm_service }} start'
|
||||
ansible.builtin.command: 'service {{ php_fpm_service }} start'
|
||||
args:
|
||||
warn: false
|
||||
when: dps.stdout.find('is not running') != -1
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
- block:
|
||||
|
||||
- name: APT | Install APCu
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "php-apcu"
|
||||
|
||||
- name: APT | Install Opcache
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ php_package_prefix }}opcache"
|
||||
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
@ -15,23 +15,29 @@
|
|||
- block:
|
||||
|
||||
- name: PKGNG | Install APCu
|
||||
pkgng:
|
||||
community.general.pkgng:
|
||||
name: "php{{ php_version | replace('.', '') }}-pecl-APCu"
|
||||
|
||||
- name: PKGNG | Install Opcache
|
||||
pkgng:
|
||||
community.general.pkgng:
|
||||
name: "{{ php_package_prefix }}opcache"
|
||||
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- name: TEMPLATE | Configure Opcache
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/__php__/mods-available/opcache.ini.j2"
|
||||
dest: "{{ php_mods_dir }}/opcache.ini"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: restart php-fpm
|
||||
|
||||
- name: TEMPLATE | Configure APCu
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/__php__/mods-available/apcu.ini.j2"
|
||||
dest: "{{ php_mods_dir }}/apcu.ini"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: restart php-fpm
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
- block:
|
||||
|
||||
- name: APT | Install xdebug
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ php_xdebug_package }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: PKGNG | Install xdebug
|
||||
pkgng:
|
||||
community.general.pkgng:
|
||||
name: "{{ php_xdebug_package }}"
|
||||
when: ansible_os_family == 'FreeBSD' and php_xdebug_package is defined
|
||||
|
||||
- name: TEMPLATE | Deploy module configurations
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/__php__/mods-available/xdebug.ini.j2"
|
||||
dest: "{{ php_mods_dir }}/xdebug.ini"
|
||||
owner: root
|
||||
|
@ -28,13 +28,13 @@
|
|||
- block:
|
||||
|
||||
- name: APT | Uninstall xdebug
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ php_xdebug_package }}"
|
||||
state: absent
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: PKGNG | Uninstall xdebug
|
||||
pkgng:
|
||||
community.general.pkgng:
|
||||
name: "{{ php_xdebug_package }}"
|
||||
state: absent
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
---
|
||||
|
||||
- name: APT | Install Sury key
|
||||
apt_key:
|
||||
ansible.builtin.apt_key:
|
||||
url: 'https://packages.sury.org/php/apt.gpg'
|
||||
|
||||
- name: APT_REPOSITORY | Add Sury repository
|
||||
apt_repository:
|
||||
ansible.builtin.apt_repository:
|
||||
repo: 'deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main'
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
---
|
||||
|
||||
- name: SET_FACT | Prepare test vars
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
__nginx_conf: /etc/nginx/nginx.conf
|
||||
|
||||
- name: APT | Install packages
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ p }}"
|
||||
update_cache: yes
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
vars:
|
||||
p:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gpg
|
||||
- lsb-release
|
||||
- nginx
|
||||
- vim
|
||||
|
||||
- name: INCLUDE_TASKS | Sury
|
||||
include_tasks: Debian/sury.yml
|
||||
when:
|
||||
((ansible_distribution_major_version is version('9', 'eq')) and (php_version is version('7.1', 'ge'))) or
|
||||
((ansible_distribution_major_version is version('10', 'eq')) and (php_version is version('7.4', 'ge')))
|
||||
ansible.builtin.include_tasks: Debian/sury.yml
|
||||
when: php_version != php_default_version
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
|
||||
- name: SET_FACT | Prepare test vars
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
__nginx_conf: /usr/local/etc/nginx/nginx.conf
|
||||
php_xdebug_package: 'php72-pecl-xdebug-2.6.1'
|
||||
|
||||
- name: PKGNG | Install packages
|
||||
pkgng:
|
||||
community.general.pkgng:
|
||||
name: ['curl', 'nginx']
|
||||
|
|
|
@ -32,38 +32,41 @@
|
|||
pre_tasks:
|
||||
|
||||
- name: INCLUDE_TASKS | Pre tasks related to OS
|
||||
include_tasks: "includes/pre_{{ ansible_os_family }}.yml"
|
||||
ansible.builtin.include_tasks: "includes/pre_{{ ansible_os_family }}.yml"
|
||||
|
||||
- name: USER | Create PHP user
|
||||
user:
|
||||
ansible.builtin.user:
|
||||
name: 'foo'
|
||||
system: yes
|
||||
create_home: no
|
||||
system: true
|
||||
create_home: false
|
||||
shell: '/usr/sbin/nologin'
|
||||
|
||||
tasks:
|
||||
|
||||
- name: TEMPLATE | Nginx site config
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "templates/nginx.conf.j2"
|
||||
dest: "{{ __nginx_conf }}"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: reload nginx
|
||||
|
||||
- name: COMMAND | Fix nginx config
|
||||
command: "cp {{ __nginx_conf | dirname }}/fastcgi_params {{ __nginx_conf | dirname }}/fastcgi.conf"
|
||||
ansible.builtin.command: "cp {{ __nginx_conf | dirname }}/fastcgi_params {{ __nginx_conf | dirname }}/fastcgi.conf"
|
||||
args:
|
||||
creates: "{{ __nginx_conf | dirname }}/fastcgi.conf"
|
||||
notify: reload nginx
|
||||
|
||||
- name: LINEINFILE | Fix nginx config (second step)
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
regexp: '^fastcgi_param\s+SCRIPT_FILENAME'
|
||||
line: "fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;"
|
||||
dest: "{{ __nginx_conf | dirname }}/fastcgi.conf"
|
||||
notify: reload nginx
|
||||
|
||||
- name: SERVICE | Ensure nginx is started
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
state: started
|
||||
when: ansible_virtualization_type != 'docker'
|
||||
|
@ -71,7 +74,7 @@
|
|||
- block:
|
||||
|
||||
- name: COMMAND | Docker nginx status
|
||||
command: service nginx status
|
||||
ansible.builtin.command: service nginx status
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
|
@ -79,7 +82,7 @@
|
|||
register: ngs
|
||||
|
||||
- name: COMMAND | Docker start nginx
|
||||
command: service nginx start
|
||||
ansible.builtin.command: service nginx start
|
||||
args:
|
||||
warn: false
|
||||
when: ngs.stdout.find('nginx is not running') != -1
|
||||
|
@ -89,13 +92,13 @@
|
|||
handlers:
|
||||
|
||||
- name: reload nginx
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
notify: docker reload nginx
|
||||
|
||||
- name: docker reload nginx
|
||||
command: service nginx reload
|
||||
ansible.builtin.command: service nginx reload
|
||||
args:
|
||||
warn: false
|
||||
notify: docker reload nginx
|
||||
|
@ -107,36 +110,48 @@
|
|||
post_tasks:
|
||||
|
||||
- name: SHELL | Test php-cli
|
||||
shell: php -i | grep '^PHP Version => {{ php_version }}' | head -n 1
|
||||
ansible.builtin.shell: set -o pipefail && php -i | grep '^PHP Version => {{ php_version }}' | head -n 1
|
||||
changed_when: false
|
||||
register: p
|
||||
failed_when: p.stdout == ''
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: FILE | Create /var/www
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
dest: /var/www
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: COPY | Add phpinfo
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
dest: /var/www/phpinfo.php
|
||||
content: '<?php phpinfo();'
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: COPY | Add ini test file
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
dest: /var/www/ini.php
|
||||
content: '<?php echo ini_get("memory_limit") . "\n";'
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- 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 {{ php_version }}' | sed -r 's/<//g'"
|
||||
ansible.builtin.shell: "set -o pipefail && curl -v -H 'Host: {{ vhost }}' http://127.0.0.1/phpinfo.php 2> /dev/null | grep h1 | grep -o 'PHP Version {{ php_version }}' | sed -r 's/<//g'"
|
||||
args:
|
||||
warn: false
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
register: c
|
||||
failed_when: c.stdout == ''
|
||||
|
||||
- name: SHELL | Check custom php value
|
||||
shell: "curl -H 'Host: {{ vhost }}' http://127.0.0.1/ini.php 2> /dev/null"
|
||||
ansible.builtin.shell: "curl -H 'Host: {{ vhost }}' http://127.0.0.1/ini.php 2> /dev/null"
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
|
@ -144,11 +159,11 @@
|
|||
failed_when: 'php_fpm_poold.1.php_admin_value.memory_limit not in c.stdout'
|
||||
|
||||
- name: URI | Check ping
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://localhost{{ php_fpm_poold.0.ping_path }}"
|
||||
when: php_fpm_poold.0.ping_path is defined
|
||||
|
||||
- name: URI | Check status
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
|
||||
when: php_fpm_poold.0.status_path is defined
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
|
||||
php_default_version: '7.4'
|
|
@ -1 +1,3 @@
|
|||
---
|
||||
|
||||
php_default_version: '7.3'
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
---
|
||||
|
||||
php_default_version: '7.0'
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
---
|
||||
|
||||
php_default_version: '7.2'
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
---
|
||||
|
||||
php_default_version: '7.2'
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
---
|
||||
|
||||
php_default_version: '7.2'
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
---
|
||||
|
||||
php_default_version: '7.0'
|
||||
|
|
Loading…
Reference in New Issue