mirror of
https://github.com/HanXHX/ansible-php.git
synced 2026-02-28 09:42:09 +07:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a51826e2f | ||
|
|
e9e74e2db6 | ||
|
|
4aef107c1a | ||
|
|
28caf6d9c9 | ||
|
|
309824dabf | ||
|
|
3209f6b010 | ||
|
|
759a85a325 | ||
|
|
704ebb3937 | ||
|
|
4feb3be7d5 | ||
|
|
c0922f8430 | ||
|
|
ade8aaad9e | ||
|
|
a19adf5150 |
8
.ansible-lint
Normal file
8
.ansible-lint
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# TODO: enable later
|
||||||
|
enable_list:
|
||||||
|
- fqcn-builtins
|
||||||
|
|
||||||
|
skip_list:
|
||||||
|
- role-name
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@
|
|||||||
*.retry
|
*.retry
|
||||||
*.log
|
*.log
|
||||||
/filter_plugins/*.pyc
|
/filter_plugins/*.pyc
|
||||||
|
/filter_plugins/__pycache__
|
||||||
|
|||||||
49
.travis.yml
49
.travis.yml
@@ -1,33 +1,36 @@
|
|||||||
|
---
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
global:
|
||||||
- PLATFORM='docker-debian-buster-php73' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
- VAGRANT_VERSION='2.2.18'
|
||||||
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
jobs:
|
||||||
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
- PLATFORM='docker-debian-buster-php73' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||||
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
- PLATFORM='docker-debian-bullseye-php74' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||||
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
- PLATFORM='docker-debian-bullseye-php80' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||||
- PLATFORM='docker-debian-stretch-php74' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
- PLATFORM='docker-debian-buster-php74' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||||
- PLATFORM='docker-debian-buster-php73' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||||
- 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'
|
|
||||||
|
|
||||||
sudo: required
|
os:
|
||||||
|
- linux
|
||||||
dist: trusty
|
dist: focal
|
||||||
|
|
||||||
language: python
|
language: python
|
||||||
python: 2.7
|
python:
|
||||||
|
- 3.8
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb
|
- sudo apt-get -q update
|
||||||
- sudo dpkg -i vagrant_2.0.1_x86_64.deb
|
- 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:
|
install:
|
||||||
- pip install "$ANSIBLE_VERSION"
|
- sudo pip install "ansible-core$ANSIBLE_VERSION"
|
||||||
|
- sudo pip install ansible-lint
|
||||||
|
- ansible-galaxy collection install community.general
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- VAGRANT_DEFAULT_PROVIDER=docker vagrant up $PLATFORM
|
- VAGRANT_DEFAULT_PROVIDER=docker vagrant up $PLATFORM
|
||||||
@@ -37,6 +40,14 @@ script:
|
|||||||
&& (echo 'Idempotence test: pass' && exit 0)
|
&& (echo 'Idempotence test: pass' && exit 0)
|
||||||
|| (echo 'Idempotence test: fail' && exit 1)
|
|| (echo 'Idempotence test: fail' && exit 1)
|
||||||
- VAGRANT_DEFAULT_PROVIDER=docker vagrant status
|
- 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:
|
notifications:
|
||||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||||
|
|||||||
6
.yamllint.yml
Normal file
6
.yamllint.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
line-length: disable
|
||||||
34
README.md
34
README.md
@@ -1,21 +1,22 @@
|
|||||||
Ansible PHP (+FPM) role for Debian / Ubuntu / FreeBSD
|
Ansible PHP (+FPM) role for Debian / Ubuntu / FreeBSD
|
||||||
=====================================================
|
=====================================================
|
||||||
|
|
||||||
[](https://galaxy.ansible.com/HanXHX/php) [](https://travis-ci.org/HanXHX/ansible-php)
|
[](https://galaxy.ansible.com/hanxhx.php) [](https://app.travis-ci.com/HanXHX/ansible-php)
|
||||||
|
|
||||||
Install PHP on Debian / Ubuntu / FreeBSD. Manage PHP-FPM, APCu, Opcache and Xdebug.
|
Install PHP on Debian / Ubuntu / FreeBSD. Manage PHP-FPM, APCu, Opcache and Xdebug.
|
||||||
|
|
||||||
Managed OS / Versions
|
Managed OS / Versions
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
| OS | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 |
|
On all Debian versions, you can install all PHP versions by using [Sury's APT repository](https://deb.sury.org/).
|
||||||
|:---------------------:|:-------------------:|:--------------------------:|:--------------------------:|:-------------------------:|:--------------------------:
|
|
||||||
| Debian Stretch (9) | :heavy_check_mark: | :heavy_check_mark: (Sury) | :heavy_check_mark: (Sury) | :heavy_check_mark: (Sury) | :heavy_check_mark: (Sury) |
|
Other cases:
|
||||||
| Debian Buster (10) | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: (Sury) |
|
|
||||||
| Ubuntu Xenial (16.04) | :heavy_check_mark: | :x: | :x: | :x: | :x: |
|
| 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... |
|
| Ubuntu Bionic (18.04) | :x: | :x: | :heavy_check_mark: | :x: | :x: |
|
||||||
| FreeBSD 12 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Need tests... |
|
| 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... |
|
||||||
|
|
||||||
Links:
|
Links:
|
||||||
- [Sury](https://deb.sury.org/)
|
- [Sury](https://deb.sury.org/)
|
||||||
@@ -23,13 +24,15 @@ Links:
|
|||||||
Requirements
|
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
|
FreeBSD limitations
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
- It doesn't split ini file for FPM/CLI. It's hardcoded as `/usr/local/etc/php.ini`.
|
- It doesn't split ini file for FPM/CLI. It's hardcoded as `/usr/local/etc/php.ini`.
|
||||||
- It can't manage multiple PHP versions at the time (like old Debian versions)
|
- It can't manage multiple PHP versions at the time (like legacy Debian versions)
|
||||||
- You must explicitely set xdebug package name (use `pkg search xdebug` to find the good one)
|
- You must explicitely set xdebug package name (use `pkg search xdebug` to find the good one)
|
||||||
|
|
||||||
Role Variables
|
Role Variables
|
||||||
@@ -39,7 +42,7 @@ You should look at [default vars](defaults/main.yml).
|
|||||||
|
|
||||||
### Writable vars
|
### Writable vars
|
||||||
|
|
||||||
- `php_version`: 7.0, 7.1, 7.2, 7.3
|
- `php_version`: 7.3, 7.4... depending OS (see above)
|
||||||
- `php_install_fpm`: boolean, install and manage php-fpm (default is true)
|
- `php_install_fpm`: boolean, install and manage php-fpm (default is true)
|
||||||
- `php_install_xdebug`: boolean, install [Xdebug](http://xdebug.org)
|
- `php_install_xdebug`: boolean, install [Xdebug](http://xdebug.org)
|
||||||
- `php_extra_packages`: additional php packages to install (default is an empty list).
|
- `php_extra_packages`: additional php packages to install (default is an empty list).
|
||||||
@@ -56,7 +59,6 @@ Note:
|
|||||||
- Put specific configuration in `php_ini_fpm`/`php_ini_cli`.
|
- Put specific configuration in `php_ini_fpm`/`php_ini_cli`.
|
||||||
- You can override with `php_ini_fpm`/`php_ini_cli`, but it breaks idempotence.
|
- You can override with `php_ini_fpm`/`php_ini_cli`, but it breaks idempotence.
|
||||||
|
|
||||||
|
|
||||||
#### OpCache settings
|
#### OpCache settings
|
||||||
|
|
||||||
See [Opcache doc](https://secure.php.net/manual/en/opcache.configuration.php)
|
See [Opcache doc](https://secure.php.net/manual/en/opcache.configuration.php)
|
||||||
@@ -159,14 +161,14 @@ Example Playbook
|
|||||||
|
|
||||||
- hosts: servers
|
- hosts: servers
|
||||||
roles:
|
roles:
|
||||||
- { role: HanXHX.php }
|
- { role: hanxhx.php }
|
||||||
|
|
||||||
### Debian Stretch with PHP 7.2 CLI (no FPM)
|
### Debian Bullseye with PHP 8.0 CLI (no FPM)
|
||||||
|
|
||||||
- hosts: servers
|
- hosts: servers
|
||||||
roles:
|
roles:
|
||||||
- { role: HanXHX.sury }
|
- { 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
|
License
|
||||||
-------
|
-------
|
||||||
|
|||||||
32
Vagrantfile
vendored
32
Vagrantfile
vendored
@@ -6,15 +6,11 @@
|
|||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
|
|
||||||
vms_debian = [
|
vms_debian = [
|
||||||
{ :name => "debian-stretch-php70", :box => "debian/stretch64", :vars => { }},
|
{ :name => "debian-buster-php73", :box => "debian/buster64", :vars => { }},
|
||||||
{ :name => "debian-stretch-php71", :box => "debian/stretch64", :vars => { "php_version": '7.1' }},
|
{ :name => "debian-buster-php74", :box => "debian/buster64", :vars => { "php_version": '7.4' }},
|
||||||
{ :name => "debian-stretch-php72", :box => "debian/stretch64", :vars => { "php_version": '7.2' }},
|
{ :name => "debian-bullseye-php74", :box => "debian/bullseye64", :vars => { }},
|
||||||
{ :name => "debian-stretch-php73", :box => "debian/stretch64", :vars => { "php_version": '7.3' }},
|
{ :name => "debian-bullseye-php80", :box => "debian/bullseye64", :vars => { "php_version": '8.0' }},
|
||||||
{ :name => "debian-stretch-php74", :box => "debian/stretch64", :vars => { "php_version": '7.4' }},
|
{ :name => "ubuntu-bionic-php72", :box => "ubuntu/bionic64", :vars => { }},
|
||||||
{ :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 => "ubuntu-bionic-php72", :box => "ubuntu/bionic64", :vars => { }},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
vms_freebsd = [
|
vms_freebsd = [
|
||||||
@@ -23,15 +19,11 @@ Vagrant.configure("2") do |config|
|
|||||||
]
|
]
|
||||||
|
|
||||||
conts = [
|
conts = [
|
||||||
{ :name => "docker-debian-stretch-php70", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { }},
|
{ :name => "docker-debian-buster-php73", :docker => "hanxhx/vagrant-ansible:debian10", :vars => { }},
|
||||||
{ :name => "docker-debian-stretch-php71", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.1' }},
|
{ :name => "docker-debian-buster-php74", :docker => "hanxhx/vagrant-ansible:debian10", :vars => { "php_version": '7.4' }},
|
||||||
{ :name => "docker-debian-stretch-php72", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.2' }},
|
{ :name => "docker-debian-bullseye-php74", :docker => "hanxhx/vagrant-ansible:debian11", :vars => { }},
|
||||||
{ :name => "docker-debian-stretch-php73", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.3' }},
|
{ :name => "docker-debian-bullseye-php80", :docker => "hanxhx/vagrant-ansible:debian11", :vars => { "php_version": '8.0' }},
|
||||||
{ :name => "docker-debian-stretch-php74", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.4' }},
|
{ :name => "docker-ubuntu-bionic-php72", :docker => "hanxhx/vagrant-ansible:ubuntu18.04", :vars => { }},
|
||||||
{ :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-ubuntu-bionic-php72", :docker => "hanxhx/vagrant-ansible:ubuntu18.04", :vars => { }},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
config.vm.network "private_network", type: "dhcp"
|
config.vm.network "private_network", type: "dhcp"
|
||||||
@@ -43,7 +35,8 @@ Vagrant.configure("2") do |config|
|
|||||||
d.remains_running = true
|
d.remains_running = true
|
||||||
d.has_ssh = true
|
d.has_ssh = true
|
||||||
end
|
end
|
||||||
m.vm.provision "shell", inline: "apt-get update && apt-get install -y python python-apt"
|
|
||||||
|
#m.vm.provision "shell", inline: "apt-get update && apt-get install -y python python-apt"
|
||||||
m.vm.provision "ansible" do |ansible|
|
m.vm.provision "ansible" do |ansible|
|
||||||
ansible.playbook = "tests/test.yml"
|
ansible.playbook = "tests/test.yml"
|
||||||
ansible.verbose = 'vv'
|
ansible.verbose = 'vv'
|
||||||
@@ -61,6 +54,7 @@ Vagrant.configure("2") do |config|
|
|||||||
v.memory = 256
|
v.memory = 256
|
||||||
end
|
end
|
||||||
m.vm.provision "shell", inline: "apt-get update && apt-get install -y ifupdown python"
|
m.vm.provision "shell", inline: "apt-get update && apt-get install -y ifupdown python"
|
||||||
|
|
||||||
m.vm.provision "ansible" do |ansible|
|
m.vm.provision "ansible" do |ansible|
|
||||||
ansible.playbook = "tests/test.yml"
|
ansible.playbook = "tests/test.yml"
|
||||||
ansible.verbose = 'vv'
|
ansible.verbose = 'vv'
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ php_install_fpm: true
|
|||||||
php_install_xdebug: false
|
php_install_xdebug: false
|
||||||
php_extra_packages: []
|
php_extra_packages: []
|
||||||
php_xdebug_package: null
|
php_xdebug_package: null
|
||||||
|
php_autoremove_default_pool: false
|
||||||
|
|
||||||
# php.ini config
|
# php.ini config
|
||||||
php_ini:
|
php_ini:
|
||||||
|
|||||||
Binary file not shown.
@@ -1,14 +1,14 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: restart php-fpm
|
- name: Restart php-fpm
|
||||||
service:
|
ansible.builtin.service:
|
||||||
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
|
notify: Docker restart php-fpm
|
||||||
|
|
||||||
- name: docker restart php-fpm
|
- name: Docker restart php-fpm
|
||||||
command: 'service {{ php_fpm_service }} restart'
|
ansible.builtin.command: 'service {{ php_fpm_service }} restart'
|
||||||
args:
|
args:
|
||||||
warn: false
|
warn: false
|
||||||
when: ansible_virtualization_type == 'docker'
|
when: ansible_virtualization_type == 'docker'
|
||||||
|
|||||||
6
meta/argument_specs.yml
Normal file
6
meta/argument_specs.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
argument_specs:
|
||||||
|
main:
|
||||||
|
short_description: Main entry point
|
||||||
|
options: {}
|
||||||
@@ -1,32 +1,34 @@
|
|||||||
---
|
---
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: Emilien Mantel
|
author: Emilien Mantel
|
||||||
description: Install and configure PHP 7.0/7.1/7.2/7.3
|
role_name: php
|
||||||
company:
|
namespace: hanxhx
|
||||||
|
description: Install and configure PHP 7.x/8.x
|
||||||
|
company: TripleStack
|
||||||
license: GPLv2
|
license: GPLv2
|
||||||
min_ansible_version: 2.6
|
min_ansible_version: '2.11'
|
||||||
platforms:
|
platforms:
|
||||||
- name: Debian
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- stretch
|
- buster
|
||||||
- buster
|
- bullseye
|
||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- xenial
|
- bionic
|
||||||
- bionic
|
- name: FreeBSD
|
||||||
- name: FreeBSD
|
versions:
|
||||||
versions:
|
- '11.0'
|
||||||
- 11.0
|
- '11.1'
|
||||||
- 11.1
|
- '12.0'
|
||||||
- 12.0
|
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- development
|
- development
|
||||||
- web
|
- web
|
||||||
- php
|
- php
|
||||||
- php-fpm
|
- fpm
|
||||||
- php7
|
- php7
|
||||||
- debian
|
- php8
|
||||||
- ubuntu
|
- debian
|
||||||
- freebsd
|
- ubuntu
|
||||||
dependencies: []
|
- freebsd
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
|
|||||||
@@ -1,36 +1,42 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: APT | Install PHP-FPM for Debian based systems
|
- name: APT | Install PHP-FPM for Debian based systems
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg: "{{ php_fpm_service }}"
|
pkg: "{{ php_fpm_service }}"
|
||||||
state: "{{ 'present' if php_install_fpm else 'absent' }}"
|
state: "{{ 'present' if php_install_fpm else 'absent' }}"
|
||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: SERVICE | Enable service on FreeBSD
|
- name: SERVICE | Enable service on FreeBSD
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: "{{ php_fpm_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'
|
when: ansible_os_family == 'FreeBSD'
|
||||||
|
|
||||||
- name: LINEINFILE | PHP configuration
|
- name: LINEINFILE | PHP configuration
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
dest: '{{ php_cli_ini }}'
|
dest: '{{ php_fpm_ini }}'
|
||||||
regexp: '^;?{{ item.key }}'
|
regexp: '^;?{{ item.key }}'
|
||||||
line: '{{ item.key }} = {{ item.value }}'
|
line: '{{ item.key }} = {{ item.value }}'
|
||||||
create: yes
|
create: true
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
loop: "{{ php_ini | combine(php_ini_fpm) | dict2items }}"
|
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:
|
ansible.builtin.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.name }}.conf'
|
dest: '{{ php_fpm_pool_dir }}/{{ item.name }}.conf'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
loop: "{{ ansible_local.hanxhx_php.fpm_pool }}"
|
loop: "{{ ansible_local.hanxhx_php.fpm_pool }}"
|
||||||
notify: restart php-fpm
|
notify: Restart php-fpm
|
||||||
|
|
||||||
- name: FILE | Delete default pool if necessary
|
- name: FILE | Delete default pool if necessary
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ php_fpm_pool_dir }}/www.conf"
|
path: "{{ php_fpm_pool_dir }}/www.conf"
|
||||||
state: absent
|
state: absent
|
||||||
when: '"www" not in (ansible_local.hanxhx_php.fpm_pool | map(attribute="name") | list)'
|
when: '"www" not in (ansible_local.hanxhx_php.fpm_pool | map(attribute="name") | list) and php_autoremove_default_pool'
|
||||||
notify: restart php-fpm
|
notify: Restart php-fpm
|
||||||
|
|||||||
@@ -1,17 +1,26 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- name: SHELL | Check if we are in multiple PHP distribution
|
||||||
|
ansible.builtin.shell: set -o pipefail && apt-cache search php xdebug | grep 'php[[:digit:]].[[:digit:]]'
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
register: multiple_php
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: INCLUDE_VARS | Related to OS family
|
- 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
|
- name: INCLUDE_VARS | Related to OS version
|
||||||
include_vars: "{{ item }}"
|
ansible.builtin.include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
|
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
|
||||||
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
|
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
|
||||||
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||||
|
|
||||||
- name: SET_FACT | Transform data
|
- name: SET_FACT | Transform data
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
__php_fpm_full_pool: |
|
__php_fpm_full_pool: |
|
||||||
[
|
[
|
||||||
{% for p in php_fpm_poold %}
|
{% for p in php_fpm_poold %}
|
||||||
@@ -20,10 +29,11 @@
|
|||||||
listen: "{{ p.listen | default(php_version | php_socket(p.name | default(p.pool_name))) }}",
|
listen: "{{ p.listen | default(php_version | php_socket(p.name | default(p.pool_name))) }}",
|
||||||
user: "{{ p.user | default(php_default_user_group) }}",
|
user: "{{ p.user | default(php_default_user_group) }}",
|
||||||
group: "{% if p.user is defined %}{{ p.group | default(p.user) }}{% else %}{{ p.group | default(php_default_user_group) }}{% endif %}",
|
group: "{% if p.user is defined %}{{ p.group | default(p.user) }}{% else %}{{ p.group | default(php_default_user_group) }}{% endif %}",
|
||||||
|
php_env: {% if p.php_env is defined %}{{ p.php_env | to_nice_json }}{% else %}{}{% endif %},
|
||||||
php_value: {% if p.php_value is defined %}{{ p.php_value | to_nice_json }}{% else %}{}{% endif %},
|
php_value: {% if p.php_value is defined %}{{ p.php_value | to_nice_json }}{% else %}{}{% endif %},
|
||||||
php_admin_value: {% if p.php_admin_value is defined %}{{ p.php_admin_value | to_nice_json }}{% else %}{}{% endif %},
|
php_admin_value: {% if p.php_admin_value is defined %}{{ p.php_admin_value | to_nice_json }}{% else %}{}{% endif %},
|
||||||
{% for k, v in p.items() | list %}
|
{% for k, v in p.items() | list %}
|
||||||
{% if k not in ['name', 'pool_name', 'listen', 'user', 'group', 'php_value', 'php_admin_value'] %}
|
{% if k not in ['name', 'pool_name', 'listen', 'user', 'group', 'php_env', 'php_value', 'php_admin_value'] %}
|
||||||
{{ k }}: "{{ v }}"{% if not loop.last %},{% endif %}
|
{{ k }}: "{{ v }}"{% if not loop.last %},{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -32,80 +42,88 @@
|
|||||||
]
|
]
|
||||||
|
|
||||||
- name: SET_FACT | To YAML
|
- name: SET_FACT | To YAML
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
php_fpm_full_pool: "{{ __php_fpm_full_pool | from_yaml }}"
|
php_fpm_full_pool: "{{ __php_fpm_full_pool | from_yaml }}"
|
||||||
|
|
||||||
- name: FILE | Creates ansible facts.d
|
- name: FILE | Creates ansible facts.d
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: /etc/ansible/facts.d
|
path: /etc/ansible/facts.d
|
||||||
state: directory
|
state: directory
|
||||||
recurse: yes
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
- name: COPY | Manage facts
|
- name: COPY | Manage facts
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
content: "{ \"fpm_pool\": {{ php_fpm_full_pool | to_nice_json }} }"
|
content: "{ \"fpm_pool\": {{ php_fpm_full_pool | to_nice_json }} }"
|
||||||
dest: /etc/ansible/facts.d/hanxhx_php.fact
|
dest: /etc/ansible/facts.d/hanxhx_php.fact
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
register: f
|
register: f
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
- name: SETUP | Gathers new facts
|
- name: SETUP | Gathers new facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
when: f.changed
|
when: f.changed
|
||||||
tags:
|
tags:
|
||||||
- skip_ansible_lint
|
- skip_ansible_lint
|
||||||
|
|
||||||
- name: APT | Install PHP packages
|
- name: APT | Install PHP packages
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg: "{{ pkgs }}"
|
pkg: "{{ pkgs }}"
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: true
|
||||||
cache_valid_time: 3600
|
cache_valid_time: 3600
|
||||||
|
install_recommends: false
|
||||||
vars:
|
vars:
|
||||||
pkgs: "{{ php_packages + php_extra_packages | flatten }}"
|
pkgs: "{{ php_packages + php_extra_packages | flatten }}"
|
||||||
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:
|
community.general.pkgng:
|
||||||
name: "{{ php_packages + php_extra_packages | flatten | join(',') }}"
|
name: "{{ php_packages + php_extra_packages | flatten | join(',') }}"
|
||||||
notify: restart php-fpm
|
notify: Restart php-fpm
|
||||||
when: ansible_os_family == 'FreeBSD'
|
when: ansible_os_family == 'FreeBSD'
|
||||||
|
|
||||||
- name: IMPORT_TASKS | PHP-FPM
|
- name: IMPORT_TASKS | PHP-FPM
|
||||||
import_tasks: fpm.yml
|
ansible.builtin.import_tasks: fpm.yml
|
||||||
|
|
||||||
- name: LINEINFILE | PHP CLI configuration
|
- name: LINEINFILE | PHP CLI configuration
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
dest: '{{ php_cli_ini }}'
|
dest: '{{ php_cli_ini }}'
|
||||||
regexp: '^;?{{ item.key }}'
|
regexp: '^;?{{ item.key }}'
|
||||||
line: '{{ item.key }} = {{ item.value }}'
|
line: '{{ item.key }} = {{ item.value }}'
|
||||||
loop: "{{ php_ini | combine(php_ini_cli) | dict2items }}"
|
loop: "{{ php_ini | combine(php_ini_cli) | dict2items }}"
|
||||||
|
|
||||||
- name: IMPORT_TASKS | Xdebug
|
- name: IMPORT_TASKS | Xdebug
|
||||||
import_tasks: xdebug.yml
|
ansible.builtin.import_tasks: xdebug.yml
|
||||||
|
|
||||||
- name: APT | Install and configure opcache
|
- name: APT | Install and configure opcache
|
||||||
import_tasks: opcache.yml
|
ansible.builtin.import_tasks: opcache.yml
|
||||||
|
|
||||||
- name: SERVICE | Ensure PHP-FPM is started
|
- name: SERVICE | Ensure PHP-FPM is started
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: '{{ php_fpm_service }}'
|
name: '{{ php_fpm_service }}'
|
||||||
state: started
|
state: started
|
||||||
when: php_install_fpm and ansible_virtualization_type != 'docker'
|
when: php_install_fpm and ansible_virtualization_type != 'docker'
|
||||||
|
|
||||||
- block:
|
- name: BLOCK | Ensure PHP-FPM is started if running on Docker
|
||||||
|
|
||||||
- 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'
|
when: php_install_fpm and ansible_virtualization_type == 'docker'
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: COMMAND | Check if PHP-FPM is started (Docker)
|
||||||
|
ansible.builtin.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)
|
||||||
|
ansible.builtin.command: 'service {{ php_fpm_service }} start'
|
||||||
|
args:
|
||||||
|
warn: false
|
||||||
|
when: dps.stdout.find('is not running') != -1
|
||||||
|
|||||||
@@ -1,37 +1,46 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- block:
|
- name: Install opcache/apcu on Debian
|
||||||
|
|
||||||
- name: APT | Install APCu
|
|
||||||
apt:
|
|
||||||
pkg: "php-apcu"
|
|
||||||
|
|
||||||
- name: APT | Install Opcache
|
|
||||||
apt:
|
|
||||||
pkg: "{{ php_package_prefix }}opcache"
|
|
||||||
|
|
||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
|
block:
|
||||||
|
|
||||||
- block:
|
- name: APT | Install APCu
|
||||||
|
ansible.builtin.apt:
|
||||||
|
pkg: "{{ php_apcu_package }}"
|
||||||
|
install_recommends: false
|
||||||
|
|
||||||
- name: PKGNG | Install APCu
|
- name: APT | Install Opcache
|
||||||
pkgng:
|
ansible.builtin.apt:
|
||||||
name: "php{{ php_version | replace('.', '') }}-pecl-APCu"
|
pkg: "{{ php_package_prefix }}opcache"
|
||||||
|
install_recommends: false
|
||||||
|
|
||||||
- name: PKGNG | Install Opcache
|
|
||||||
pkgng:
|
|
||||||
name: "{{ php_package_prefix }}opcache"
|
|
||||||
|
|
||||||
|
- name: Install opcache/apcu on FreeBSD
|
||||||
when: ansible_os_family == 'FreeBSD'
|
when: ansible_os_family == 'FreeBSD'
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: PKGNG | Install APCu
|
||||||
|
community.general.pkgng:
|
||||||
|
name: "php{{ php_version | replace('.', '') }}-pecl-APCu"
|
||||||
|
|
||||||
|
- name: PKGNG | Install Opcache
|
||||||
|
community.general.pkgng:
|
||||||
|
name: "{{ php_package_prefix }}opcache"
|
||||||
|
|
||||||
- name: TEMPLATE | Configure Opcache
|
- name: TEMPLATE | Configure Opcache
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: "etc/__php__/mods-available/opcache.ini.j2"
|
src: "etc/__php__/mods-available/opcache.ini.j2"
|
||||||
dest: "{{ php_mods_dir }}/opcache.ini"
|
dest: "{{ php_mods_dir }}/opcache.ini"
|
||||||
notify: restart php-fpm
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: Restart php-fpm
|
||||||
|
|
||||||
- name: TEMPLATE | Configure APCu
|
- name: TEMPLATE | Configure APCu
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: "etc/__php__/mods-available/apcu.ini.j2"
|
src: "etc/__php__/mods-available/apcu.ini.j2"
|
||||||
dest: "{{ php_mods_dir }}/apcu.ini"
|
dest: "{{ php_mods_dir }}/apcu.ini"
|
||||||
notify: restart php-fpm
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: Restart php-fpm
|
||||||
|
|||||||
@@ -1,42 +1,44 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- block:
|
- name: BLOCK | Uninstall xdebug
|
||||||
|
|
||||||
- name: APT | Install xdebug
|
|
||||||
apt:
|
|
||||||
pkg: "{{ php_xdebug_package }}"
|
|
||||||
state: present
|
|
||||||
update_cache: yes
|
|
||||||
cache_valid_time: 3600
|
|
||||||
when: ansible_os_family == 'Debian'
|
|
||||||
|
|
||||||
- name: PKGNG | Install xdebug
|
|
||||||
pkgng:
|
|
||||||
name: "{{ php_xdebug_package }}"
|
|
||||||
when: ansible_os_family == 'FreeBSD' and php_xdebug_package is defined
|
|
||||||
|
|
||||||
- name: TEMPLATE | Deploy module configurations
|
|
||||||
template:
|
|
||||||
src: "etc/__php__/mods-available/xdebug.ini.j2"
|
|
||||||
dest: "{{ php_mods_dir }}/xdebug.ini"
|
|
||||||
owner: root
|
|
||||||
mode: 0644
|
|
||||||
notify: restart php-fpm
|
|
||||||
|
|
||||||
when: php_install_xdebug
|
when: php_install_xdebug
|
||||||
|
block:
|
||||||
|
|
||||||
- block:
|
- name: APT | Install xdebug
|
||||||
|
ansible.builtin.apt:
|
||||||
|
pkg: "{{ php_xdebug_package }}"
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
|
install_recommends: false
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: APT | Uninstall xdebug
|
- name: PKGNG | Install xdebug
|
||||||
apt:
|
community.general.pkgng:
|
||||||
pkg: "{{ php_xdebug_package }}"
|
name: "{{ php_xdebug_package }}"
|
||||||
state: absent
|
when: ansible_os_family == 'FreeBSD' and php_xdebug_package is defined
|
||||||
when: ansible_os_family == 'Debian'
|
|
||||||
|
|
||||||
- name: PKGNG | Uninstall xdebug
|
- name: TEMPLATE | Deploy module configurations
|
||||||
pkgng:
|
ansible.builtin.template:
|
||||||
name: "{{ php_xdebug_package }}"
|
src: "etc/__php__/mods-available/xdebug.ini.j2"
|
||||||
state: absent
|
dest: "{{ php_mods_dir }}/xdebug.ini"
|
||||||
when: ansible_os_family == 'FreeBSD'
|
owner: root
|
||||||
|
mode: 0644
|
||||||
|
notify: Restart php-fpm
|
||||||
|
|
||||||
|
|
||||||
|
- name: BLOCK | Uninstall xdebug
|
||||||
when: not php_install_xdebug
|
when: not php_install_xdebug
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: APT | Uninstall xdebug
|
||||||
|
ansible.builtin.apt:
|
||||||
|
pkg: "{{ php_xdebug_package }}"
|
||||||
|
state: absent
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
|
- name: PKGNG | Uninstall xdebug
|
||||||
|
community.general.pkgng:
|
||||||
|
name: "{{ php_xdebug_package }}"
|
||||||
|
state: absent
|
||||||
|
when: ansible_os_family == 'FreeBSD'
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ pm.process_idle_timeout = {{ item.pm_process_idle_timeout | default('10s') }};
|
|||||||
; This can be useful to work around memory leaks in 3rd party libraries. For
|
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||||
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||||
; Default Value: 0
|
; Default Value: 0
|
||||||
;pm.max_requests = 500
|
pm.max_requests = {{ item.pm_max_requests | default('0') }}
|
||||||
|
|
||||||
; The URI to view the FPM status page. If this value is not set, no URI will be
|
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||||
; recognized as a status page. It shows the following informations:
|
; recognized as a status page. It shows the following informations:
|
||||||
@@ -421,6 +421,9 @@ catch_workers_output = {{ item.catch_workers_output | default('no') }}
|
|||||||
;php_admin_value[error_log] = /var/log/fpm-php.www.log
|
;php_admin_value[error_log] = /var/log/fpm-php.www.log
|
||||||
;php_admin_flag[log_errors] = on
|
;php_admin_flag[log_errors] = on
|
||||||
;php_admin_value[memory_limit] = 32M
|
;php_admin_value[memory_limit] = 32M
|
||||||
|
{% for k, v in item.php_env.items() | list %}
|
||||||
|
env[{{ k }}] = {{ v }}
|
||||||
|
{% endfor %}
|
||||||
{% for k, v in item.php_value.items() | list %}
|
{% for k, v in item.php_value.items() | list %}
|
||||||
php_value[{{ k }}] = {{ v }}
|
php_value[{{ k }}] = {{ v }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: APT | Install Sury key
|
- name: APT | Install Sury key
|
||||||
apt_key:
|
ansible.builtin.apt_key:
|
||||||
url: 'https://packages.sury.org/php/apt.gpg'
|
url: 'https://packages.sury.org/php/apt.gpg'
|
||||||
|
|
||||||
- name: APT_REPOSITORY | Add Sury repository
|
- name: APT_REPOSITORY | Add Sury repository
|
||||||
apt_repository:
|
ansible.builtin.apt_repository:
|
||||||
repo: 'deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main'
|
repo: 'deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main'
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: SET_FACT | Prepare test vars
|
- name: SET_FACT | Prepare test vars
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
__nginx_conf: /etc/nginx/nginx.conf
|
__nginx_conf: /etc/nginx/nginx.conf
|
||||||
|
|
||||||
- name: APT | Install packages
|
- name: APT | Install packages
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg: "{{ p }}"
|
pkg: "{{ p }}"
|
||||||
update_cache: yes
|
update_cache: true
|
||||||
cache_valid_time: 3600
|
cache_valid_time: 3600
|
||||||
vars:
|
vars:
|
||||||
p:
|
p:
|
||||||
- apt-transport-https
|
- apt-transport-https
|
||||||
- ca-certificates
|
- ca-certificates
|
||||||
- curl
|
- curl
|
||||||
|
- gpg
|
||||||
- lsb-release
|
- lsb-release
|
||||||
- nginx
|
- nginx
|
||||||
- vim
|
- vim
|
||||||
|
|
||||||
- name: INCLUDE_TASKS | Sury
|
- name: INCLUDE_TASKS | Sury
|
||||||
include_tasks: Debian/sury.yml
|
ansible.builtin.include_tasks: Debian/sury.yml
|
||||||
when:
|
when: php_version != php_default_version
|
||||||
((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')))
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: SET_FACT | Prepare test vars
|
- name: SET_FACT | Prepare test vars
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
__nginx_conf: /usr/local/etc/nginx/nginx.conf
|
__nginx_conf: /usr/local/etc/nginx/nginx.conf
|
||||||
php_xdebug_package: 'php72-pecl-xdebug-2.6.1'
|
php_xdebug_package: 'php72-pecl-xdebug-2.6.1'
|
||||||
|
|
||||||
- name: PKGNG | Install packages
|
- name: PKGNG | Install packages
|
||||||
pkgng:
|
community.general.pkgng:
|
||||||
name: ['curl', 'nginx']
|
name: ['curl', 'nginx']
|
||||||
|
|||||||
121
tests/test.yml
121
tests/test.yml
@@ -1,11 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- hosts: all
|
- hosts: all
|
||||||
|
name: Test all
|
||||||
vars:
|
vars:
|
||||||
vhost: 'test.local'
|
vhost: 'test.local'
|
||||||
php_extra_packages:
|
php_extra_packages:
|
||||||
- '{{ php_package_prefix }}pgsql'
|
- '{{ php_package_prefix }}pgsql'
|
||||||
php_install_xdebug: true
|
php_install_xdebug: true
|
||||||
|
php_autoremove_default_pool: true
|
||||||
php_ini_fpm:
|
php_ini_fpm:
|
||||||
display_errors: 'Off'
|
display_errors: 'Off'
|
||||||
php_ini_cli:
|
php_ini_cli:
|
||||||
@@ -23,6 +25,8 @@
|
|||||||
ping_response: 'ok'
|
ping_response: 'ok'
|
||||||
- name: 'test_ansible2'
|
- name: 'test_ansible2'
|
||||||
user: 'foo'
|
user: 'foo'
|
||||||
|
php_env:
|
||||||
|
foo: bar
|
||||||
php_value:
|
php_value:
|
||||||
display_errors: 'Off'
|
display_errors: 'Off'
|
||||||
php_admin_value:
|
php_admin_value:
|
||||||
@@ -31,73 +35,76 @@
|
|||||||
pre_tasks:
|
pre_tasks:
|
||||||
|
|
||||||
- name: INCLUDE_TASKS | Pre tasks related to OS
|
- 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
|
- name: USER | Create PHP user
|
||||||
user:
|
ansible.builtin.user:
|
||||||
name: 'foo'
|
name: 'foo'
|
||||||
system: yes
|
system: true
|
||||||
create_home: no
|
create_home: false
|
||||||
shell: '/usr/sbin/nologin'
|
shell: '/usr/sbin/nologin'
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: TEMPLATE | Nginx site config
|
- name: TEMPLATE | Nginx site config
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: "templates/nginx.conf.j2"
|
src: "templates/nginx.conf.j2"
|
||||||
dest: "{{ __nginx_conf }}"
|
dest: "{{ __nginx_conf }}"
|
||||||
notify: reload nginx
|
mode: 0644
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
notify: Reload nginx
|
||||||
|
|
||||||
- name: COMMAND | Fix nginx config
|
- 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:
|
args:
|
||||||
creates: "{{ __nginx_conf | dirname }}/fastcgi.conf"
|
creates: "{{ __nginx_conf | dirname }}/fastcgi.conf"
|
||||||
notify: reload nginx
|
notify: Reload nginx
|
||||||
|
|
||||||
- name: LINEINFILE | Fix nginx config (second step)
|
- name: LINEINFILE | Fix nginx config (second step)
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
regexp: '^fastcgi_param\s+SCRIPT_FILENAME'
|
regexp: '^fastcgi_param\s+SCRIPT_FILENAME'
|
||||||
line: "fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;"
|
line: "fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;"
|
||||||
dest: "{{ __nginx_conf | dirname }}/fastcgi.conf"
|
dest: "{{ __nginx_conf | dirname }}/fastcgi.conf"
|
||||||
notify: reload nginx
|
notify: Reload nginx
|
||||||
|
|
||||||
- name: SERVICE | Ensure nginx is started
|
- name: SERVICE | Ensure nginx is started
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: nginx
|
name: nginx
|
||||||
state: started
|
state: started
|
||||||
when: ansible_virtualization_type != 'docker'
|
when: ansible_virtualization_type != 'docker'
|
||||||
|
|
||||||
- block:
|
- name: Start nginx if testing with Docker
|
||||||
|
|
||||||
- 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'
|
when: ansible_virtualization_type == 'docker'
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: COMMAND | Docker nginx status
|
||||||
|
ansible.builtin.command: service nginx status
|
||||||
|
args:
|
||||||
|
warn: false
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
register: ngs
|
||||||
|
|
||||||
|
- name: COMMAND | Docker start nginx
|
||||||
|
ansible.builtin.command: service nginx start
|
||||||
|
args:
|
||||||
|
warn: false
|
||||||
|
when: ngs.stdout.find('nginx is not running') != -1
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
|
|
||||||
- name: reload nginx
|
- name: Reload nginx
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: nginx
|
name: nginx
|
||||||
state: reloaded
|
state: reloaded
|
||||||
notify: docker reload nginx
|
notify: Docker reload nginx
|
||||||
|
|
||||||
- name: docker reload nginx
|
- name: Docker reload nginx
|
||||||
command: service nginx reload
|
ansible.builtin.command: service nginx reload
|
||||||
args:
|
args:
|
||||||
warn: false
|
warn: false
|
||||||
notify: docker reload nginx
|
notify: Docker reload nginx
|
||||||
when: ansible_virtualization_type == 'docker'
|
when: ansible_virtualization_type == 'docker'
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
@@ -106,36 +113,48 @@
|
|||||||
post_tasks:
|
post_tasks:
|
||||||
|
|
||||||
- name: SHELL | Test php-cli
|
- 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
|
changed_when: false
|
||||||
register: p
|
register: p
|
||||||
failed_when: p.stdout == ''
|
failed_when: p.stdout == ''
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
|
||||||
- name: FILE | Create /var/www
|
- name: FILE | Create /var/www
|
||||||
file:
|
ansible.builtin.file:
|
||||||
dest: /var/www
|
dest: /var/www
|
||||||
state: directory
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
- name: COPY | Add phpinfo
|
- name: COPY | Add phpinfo
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
dest: /var/www/phpinfo.php
|
dest: /var/www/phpinfo.php
|
||||||
content: '<?php phpinfo();'
|
content: '<?php phpinfo();'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
- name: COPY | Add ini test file
|
- name: COPY | Add ini test file
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
dest: /var/www/ini.php
|
dest: /var/www/ini.php
|
||||||
content: '<?php echo ini_get("memory_limit") . "\n";'
|
content: '<?php echo ini_get("memory_limit") . "\n";'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
- name: SHELL | Check vhost
|
- 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:
|
args:
|
||||||
warn: false
|
warn: false
|
||||||
|
executable: /bin/bash
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: c
|
register: c
|
||||||
failed_when: c.stdout == ''
|
failed_when: c.stdout == ''
|
||||||
|
|
||||||
- name: SHELL | Check custom php value
|
- 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:
|
args:
|
||||||
warn: false
|
warn: false
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@@ -143,11 +162,29 @@
|
|||||||
failed_when: 'php_fpm_poold.1.php_admin_value.memory_limit not in c.stdout'
|
failed_when: 'php_fpm_poold.1.php_admin_value.memory_limit not in c.stdout'
|
||||||
|
|
||||||
- name: URI | Check ping
|
- name: URI | Check ping
|
||||||
uri:
|
ansible.builtin.uri:
|
||||||
url: "http://localhost{{ php_fpm_poold.0.ping_path }}"
|
url: "http://localhost{{ php_fpm_poold.0.ping_path }}"
|
||||||
when: php_fpm_poold.0.ping_path is defined
|
when: php_fpm_poold.0.ping_path is defined
|
||||||
|
|
||||||
- name: URI | Check status
|
- name: URI | Check status
|
||||||
uri:
|
ansible.builtin.uri:
|
||||||
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
|
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
|
||||||
when: php_fpm_poold.0.status_path is defined
|
when: php_fpm_poold.0.status_path is defined
|
||||||
|
|
||||||
|
- name: Debian extra checks
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: SHELL | Check if we installed multiple PHP versions
|
||||||
|
ansible.builtin.shell: set -o pipefail && (dpkg -l | grep 'php[[:digit:]].*common' | wc -l)
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
register: check_multiple_php
|
||||||
|
|
||||||
|
|
||||||
|
- name: FAIL | If we have multiple PHP version
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "Multiple PHP versions detected"
|
||||||
|
when: check_multiple_php.stdout != '1'
|
||||||
|
|||||||
3
vars/Debian-bullseye.yml
Normal file
3
vars/Debian-bullseye.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
php_default_version: '7.4'
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
php_default_version: '7.3'
|
php_default_version: '7.3'
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
php_default_version: '7.0'
|
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
php_default_version: '7.2'
|
php_default_version: '7.2'
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
php_default_version: '7.2'
|
php_default_version: '7.2'
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ php_packages:
|
|||||||
- '{{ php_package_prefix }}mysql'
|
- '{{ php_package_prefix }}mysql'
|
||||||
- '{{ php_package_prefix }}intl'
|
- '{{ php_package_prefix }}intl'
|
||||||
|
|
||||||
php_xdebug_package: 'php-xdebug'
|
php_xdebug_package: '{% if multiple_php.rc == 0 %}{{ php_package_prefix }}{% else %}php-{% endif %}xdebug'
|
||||||
|
php_apcu_package: '{% if multiple_php.rc == 0 %}{{ php_package_prefix }}{% else %}php-{% endif %}apcu'
|
||||||
|
|
||||||
php_package_prefix: 'php{{ php_version }}-'
|
php_package_prefix: 'php{{ php_version }}-'
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
php_default_version: '7.2'
|
php_default_version: '7.2'
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
php_default_version: '7.0'
|
php_default_version: '7.0'
|
||||||
|
|||||||
Reference in New Issue
Block a user