mirror of
https://github.com/HanXHX/ansible-php.git
synced 2026-02-28 09:42:09 +07:00
Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2723adf574 | ||
|
|
4aeea704d5 | ||
|
|
4615168559 | ||
|
|
1e4edc9ed4 | ||
|
|
b0834f9a1a | ||
|
|
f6652efe77 | ||
|
|
0a9a5c7aaf | ||
|
|
726d769d26 | ||
|
|
b363238e10 | ||
|
|
73355bfe30 | ||
|
|
f54176c880 | ||
|
|
ec779b858a | ||
|
|
539dc205f5 | ||
|
|
85378ac422 | ||
|
|
483b6c78b5 | ||
|
|
746b05ca4a | ||
|
|
b4afb45dd4 | ||
|
|
0a51826e2f | ||
|
|
e9e74e2db6 | ||
|
|
4aef107c1a | ||
|
|
28caf6d9c9 | ||
|
|
309824dabf | ||
|
|
3209f6b010 | ||
|
|
759a85a325 | ||
|
|
704ebb3937 | ||
|
|
4feb3be7d5 | ||
|
|
c0922f8430 | ||
|
|
ade8aaad9e | ||
|
|
a19adf5150 | ||
|
|
9738ae9614 | ||
|
|
73fa4dc212 | ||
|
|
75f09eaf59 | ||
|
|
5abe99568a | ||
|
|
8b2c92a047 | ||
|
|
0171ae8e20 | ||
|
|
95892782ea | ||
|
|
f5b9eb78b7 | ||
|
|
5ef6d09ac6 | ||
|
|
e45df940cd | ||
|
|
6c3aa5443a | ||
|
|
847941ebc6 | ||
|
|
feff5576d2 | ||
|
|
04547b496f | ||
|
|
9f048ae918 | ||
|
|
6a85f02fc1 | ||
|
|
4611a5a795 | ||
|
|
9e59ba5b47 | ||
|
|
9aa0f76c03 | ||
|
|
e87d158424 | ||
|
|
5878040e84 | ||
|
|
8e53b9cd80 | ||
|
|
cbceba6897 | ||
|
|
d836862837 | ||
|
|
df8b58b46a | ||
|
|
de41097cde | ||
|
|
71721d1afc | ||
|
|
3d7c68e700 | ||
|
|
6d4a7e1a08 | ||
|
|
f8ddae5064 | ||
|
|
f38aa400b3 | ||
|
|
8758a9b7dc | ||
|
|
2a6b921b5e | ||
|
|
1bce22acbd | ||
|
|
7f7087cdb2 | ||
|
|
2987051153 | ||
|
|
7727e19da9 | ||
|
|
bc501c9e25 | ||
|
|
9111165a7c | ||
|
|
ef9242f2fb |
12
.config/ansible-lint.yml
Normal file
12
.config/ansible-lint.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
profile: production
|
||||||
|
|
||||||
|
warn_list: []
|
||||||
|
|
||||||
|
skip_list: []
|
||||||
|
|
||||||
|
exclude_paths:
|
||||||
|
- .github/
|
||||||
|
- .venv/
|
||||||
|
- venv/
|
||||||
17
.github/workflows/ansible-galaxy.yml
vendored
Normal file
17
.github/workflows/ansible-galaxy.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
name: Deploy on Ansible Galaxy
|
||||||
|
|
||||||
|
'on':
|
||||||
|
- push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: galaxy
|
||||||
|
uses: robertdebock/galaxy-action@1.2.0
|
||||||
|
with:
|
||||||
|
galaxy_api_key: ${{ secrets.galaxy_api_key }}
|
||||||
39
.github/workflows/ci.yml
vendored
Normal file
39
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
name: ci
|
||||||
|
'on':
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
yaml-lint:
|
||||||
|
name: YAML Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Fetch code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python 3.
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
|
||||||
|
- name: Install test dependencies.
|
||||||
|
run: pip3 install yamllint
|
||||||
|
|
||||||
|
- name: Lint code.
|
||||||
|
run: |
|
||||||
|
yamllint .
|
||||||
|
|
||||||
|
ansible-lint:
|
||||||
|
name: Ansible Lint
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Run ansible-lint
|
||||||
|
uses: ansible/ansible-lint@main
|
||||||
43
.github/workflows/molecule.yml
vendored
Normal file
43
.github/workflows/molecule.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
name: Molecule
|
||||||
|
|
||||||
|
'on':
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
scenario:
|
||||||
|
- debian-11
|
||||||
|
- debian-12
|
||||||
|
- ubuntu-20.04
|
||||||
|
- ubuntu-22.04
|
||||||
|
- ubuntu-24.04
|
||||||
|
allowed-to-fail:
|
||||||
|
- false
|
||||||
|
include:
|
||||||
|
- scenario: debian-13
|
||||||
|
allowed-to-fail: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
path: "${{ github.repository }}"
|
||||||
|
|
||||||
|
- name: Molecule
|
||||||
|
uses: gofrolist/molecule-action@v2.7.62
|
||||||
|
with:
|
||||||
|
molecule_options: --base-config molecule/_shared/base.yml
|
||||||
|
molecule_args: --scenario-name ${{ matrix.scenario }}
|
||||||
|
continue-on-error: ${{ matrix.allowed-to-fail }}
|
||||||
|
|
||||||
|
- name: Fake command
|
||||||
|
run: echo "End of job"
|
||||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,3 +1,9 @@
|
|||||||
.vagrant*
|
|
||||||
*.swp
|
*.swp
|
||||||
*.retry
|
*.retry
|
||||||
|
*.log
|
||||||
|
/filter_plugins/*.pyc
|
||||||
|
/filter_plugins/__pycache__
|
||||||
|
/.idea
|
||||||
|
/.venv
|
||||||
|
/venv
|
||||||
|
/.ansible
|
||||||
|
|||||||
16
.travis.yml
16
.travis.yml
@@ -1,16 +0,0 @@
|
|||||||
env:
|
|
||||||
- PLATFORM=debian-jessie-php-5.6
|
|
||||||
- PLATFORM=debian-jessie-php-7.0
|
|
||||||
|
|
||||||
sudo: required
|
|
||||||
|
|
||||||
language: python
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
script:
|
|
||||||
- docker build -f tests/$PLATFORM.Dockerfile -t test-$PLATFORM . && docker run --name $PLATFORM test-$PLATFORM
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
|
||||||
8
.yamllint.yml
Normal file
8
.yamllint.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
line-length: disable
|
||||||
|
|
||||||
|
ignore-from-file: .gitignore
|
||||||
57
README.md
57
README.md
@@ -1,17 +1,24 @@
|
|||||||
Ansible PHP (+FPM) role for Debian
|
Ansible PHP (+FPM) role for Debian / Ubuntu
|
||||||
==================================
|
===========================================
|
||||||
|
|
||||||
[](https://galaxy.ansible.com/HanXHX/php) [](https://travis-ci.org/HanXHX/ansible-php)
|
[](https://galaxy.ansible.com/hanxhx.php) 
|
||||||
|
|
||||||
Install PHP (php-fpm optional) on Debian Jessie/Stretch. Manage APCu, Opcache, Xdebug.
|
Install PHP on Debian / Ubuntu. Manage PHP-FPM, APCu, Opcache and Xdebug.
|
||||||
|
|
||||||
Managed versions: 5.6 and 7.0
|
Managed OS / Versions
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
On all Debian versions, you can install all PHP versions (from PHP 5.6 to latest version) by using [Sury's APT repository](https://deb.sury.org/).
|
||||||
|
|
||||||
|
Links:
|
||||||
|
- [Sury](https://deb.sury.org/)
|
||||||
|
|
||||||
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
|
||||||
On Debian Jessie, if you want PHP7.0, you must use [Dotdeb](https://www.dotdeb.org). You can use my [dotdeb role](https://github.com/HanXHX/ansible-debian-dotdeb).
|
- 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).
|
||||||
|
|
||||||
Role Variables
|
Role Variables
|
||||||
--------------
|
--------------
|
||||||
@@ -20,7 +27,7 @@ You should look at [default vars](defaults/main.yml).
|
|||||||
|
|
||||||
### Writable vars
|
### Writable vars
|
||||||
|
|
||||||
- `php_version`: 5.6 (default) or 7.0
|
- `php_version`: 7.3, 7.4... depending on OS
|
||||||
- `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).
|
||||||
@@ -37,7 +44,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)
|
||||||
@@ -138,24 +144,39 @@ Example Playbook
|
|||||||
|
|
||||||
### Simple Playbook
|
### Simple Playbook
|
||||||
|
|
||||||
- hosts: servers
|
```yaml
|
||||||
roles:
|
- hosts: servers
|
||||||
- { role: HanXHX.php }
|
roles:
|
||||||
|
- { role: HanXHX.php }
|
||||||
|
```
|
||||||
|
|
||||||
### Debian Jessie with PHP 7.0 CLI (no FPM)
|
### Debian Bullseye with PHP 8.0 CLI (no FPM)
|
||||||
|
|
||||||
- hosts: jessie-servers
|
```yaml
|
||||||
roles:
|
- hosts: servers
|
||||||
- { role: HanXHX.dotdeb }
|
roles:
|
||||||
- { role: HanXHX.php, php_version: '7.0', php_install_fpm: false }
|
- { role: HanXHX.sury }
|
||||||
|
- { role: HanXHX.php, php_version: '8.0', php_install_fpm: false }
|
||||||
|
```
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
GPLv2
|
GPLv2
|
||||||
|
|
||||||
|
Donation
|
||||||
|
--------
|
||||||
|
|
||||||
|
If this code helped you, or if you’ve used them for your projects, feel free to buy me some :beers:
|
||||||
|
|
||||||
|
- Bitcoin: `1BQwhBeszzWbUTyK4aUyq3SRg7rBSHcEQn`
|
||||||
|
- Ethereum: `0x63abe6b2648fd892816d87a31e3d9d4365a737b5`
|
||||||
|
- Litecoin: `LeNDw34zQLX84VvhCGADNvHMEgb5QyFXyD`
|
||||||
|
- Monero: `45wbf7VdQAZS5EWUrPhen7Wo4hy7Pa7c7ZBdaWQSRowtd3CZ5vpVw5nTPphTuqVQrnYZC72FXDYyfP31uJmfSQ6qRXFy3bQ`
|
||||||
|
|
||||||
|
No cryptocurrency? :star: the project is also a way of saying thank you! :sunglasses:
|
||||||
|
|
||||||
Author Information
|
Author Information
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
- Twitter: [@hanxhx_](https://twitter.com/hanxhx_)
|
- Twitter: [@hanxhx_](https://twitter.com/hanxhx_)
|
||||||
- All issues, pull-requests are welcome :)
|
|
||||||
|
|||||||
35
Vagrantfile
vendored
35
Vagrantfile
vendored
@@ -1,35 +0,0 @@
|
|||||||
# -*- mode: ruby -*-
|
|
||||||
# vi: set ft=ruby :
|
|
||||||
# vi: set tabstop=2 :
|
|
||||||
# vi: set shiftwidth=2 :
|
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
|
|
||||||
vms = [
|
|
||||||
[ "jessie-php-5.6", "debian/contrib-jessie64", "192.168.33.88", "5.6" ],
|
|
||||||
[ "jessie-php-7.0", "debian/contrib-jessie64", "192.168.33.89", "7.0" ],
|
|
||||||
[ "stretch-php-5.6", "sharlak/debian_stretch_64", "192.168.33.90", "5.6" ],
|
|
||||||
[ "stretch-php-7.0", "sharlak/debian_stretch_64", "192.168.33.91", "7.0" ]
|
|
||||||
]
|
|
||||||
|
|
||||||
config.vm.provider "virtualbox" do |v|
|
|
||||||
v.cpus = 1
|
|
||||||
v.memory = 256
|
|
||||||
end
|
|
||||||
|
|
||||||
vms.each do |vm|
|
|
||||||
config.vm.define vm[0] do |m|
|
|
||||||
m.vm.box = vm[1]
|
|
||||||
m.vm.network "private_network", ip: vm[2]
|
|
||||||
|
|
||||||
m.vm.provision "ansible" do |ansible|
|
|
||||||
ansible.playbook = "tests/test.yml"
|
|
||||||
ansible.verbose = 'vv'
|
|
||||||
ansible.sudo = true
|
|
||||||
ansible.extra_vars = {
|
|
||||||
php_version: vm[3]
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
php_version: '5.6'
|
php_version: '{{ php_default_version }}'
|
||||||
php_install_fpm: true
|
php_install_fpm: true
|
||||||
php_install_xdebug: false
|
php_install_xdebug: false
|
||||||
php_extra_packages: []
|
php_extra_packages: []
|
||||||
|
php_xdebug_package: null
|
||||||
|
php_autoremove_default_pool: false
|
||||||
|
|
||||||
# php.ini config
|
# php.ini config
|
||||||
php_ini:
|
php_ini:
|
||||||
- key: 'date.timezone'
|
'date.timezone': 'Europe/Paris'
|
||||||
value: 'Europe/Paris'
|
'expose_php': 'Off'
|
||||||
- key: 'expose_php'
|
'memory_limit': '256M'
|
||||||
value: 'Off'
|
php_ini_fpm: {}
|
||||||
- key: 'memory_limit'
|
php_ini_cli: {}
|
||||||
value: '256M'
|
|
||||||
php_ini_fpm: []
|
|
||||||
php_ini_cli: []
|
|
||||||
|
|
||||||
# OpCache settings
|
# OpCache settings
|
||||||
php_opcache_enable: "1"
|
php_opcache_enable: "1"
|
||||||
@@ -92,11 +91,13 @@ php_xdebug_var_display_max_depth: '3'
|
|||||||
|
|
||||||
# PHP-FPM
|
# PHP-FPM
|
||||||
php_fpm_poold:
|
php_fpm_poold:
|
||||||
- pool_name: 'www'
|
- name: 'www'
|
||||||
listen: '{{ php_default_fpm_sock }}'
|
listen: '{{ php_default_fpm_sock }}'
|
||||||
pm: 'dynamic'
|
pm: 'dynamic'
|
||||||
pm_max_children: 250
|
pm_max_children: 100
|
||||||
pm_start_servers: 10
|
pm_start_servers: 10
|
||||||
pm_min_spare_servers: 10
|
pm_min_spare_servers: 10
|
||||||
pm_max_spare_servers: 20
|
pm_max_spare_servers: 20
|
||||||
|
|
||||||
|
# Hack
|
||||||
|
php_default_version: 'NONE'
|
||||||
|
|||||||
10
filter_plugins/php.py
Normal file
10
filter_plugins/php.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
def php_socket(php_version, pool_name):
|
||||||
|
return '/run/php/php%s-%s-fpm.sock' % (php_version, pool_name)
|
||||||
|
|
||||||
|
class FilterModule(object):
|
||||||
|
''' PHP module '''
|
||||||
|
|
||||||
|
def filters(self):
|
||||||
|
return {
|
||||||
|
'php_socket': php_socket,
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: restart php-fpm
|
- name: Restart php-fpm
|
||||||
service: name='{{ php_fpm_service }}' state=restarted
|
ansible.builtin.service:
|
||||||
|
name: '{{ php_fpm_service }}'
|
||||||
|
state: restarted
|
||||||
when: php_install_fpm
|
when: php_install_fpm
|
||||||
|
|||||||
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,19 +1,30 @@
|
|||||||
---
|
---
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: Emilien Mantel
|
author: Emilien Mantel
|
||||||
description: Install and configure PHP 5.6/7.0 (+ FPM is wanted)
|
namespace: HanXHX
|
||||||
company:
|
role_name: php
|
||||||
|
description: Install and configure PHP 7.x/8.x
|
||||||
|
company: TripleStack
|
||||||
license: GPLv2
|
license: GPLv2
|
||||||
min_ansible_version: 1.9
|
min_ansible_version: "2.18"
|
||||||
platforms:
|
platforms:
|
||||||
- name: Debian
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- jessie
|
- bullseye
|
||||||
|
- bookworm
|
||||||
|
- trixie
|
||||||
|
- name: Ubuntu
|
||||||
|
versions:
|
||||||
|
- focal
|
||||||
|
- jammy
|
||||||
|
- noble
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- development
|
- development
|
||||||
- web
|
- web
|
||||||
- php
|
- php
|
||||||
- php7
|
- fpm
|
||||||
- debian
|
- php7
|
||||||
|
- php8
|
||||||
|
- debian
|
||||||
|
- ubuntu
|
||||||
dependencies: []
|
dependencies: []
|
||||||
|
|
||||||
|
|||||||
19
molecule/_shared/Dockerfile.j2
Normal file
19
molecule/_shared/Dockerfile.j2
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Molecule managed
|
||||||
|
|
||||||
|
{% if item.registry is defined %}
|
||||||
|
FROM {{ item.registry.url }}/{{ item.image }}
|
||||||
|
{% else %}
|
||||||
|
FROM {{ item.image }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if item.env is defined %}
|
||||||
|
{% for var, value in item.env.items() %}
|
||||||
|
{% if value %}
|
||||||
|
ENV {{ var }} {{ value }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y python3 sudo bash ca-certificates iproute2 python-apt-common \
|
||||||
|
&& apt-get clean
|
||||||
42
molecule/_shared/base.yml
Normal file
42
molecule/_shared/base.yml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
scenario:
|
||||||
|
test_sequence:
|
||||||
|
- dependency
|
||||||
|
- syntax
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
- converge
|
||||||
|
- idempotence
|
||||||
|
- verify
|
||||||
|
- destroy
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
options:
|
||||||
|
requirements-file: ./molecule/_shared/requirements.yml
|
||||||
|
role-file: ./molecule/_shared/requirements.yml
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
role_name_check: 1
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
env:
|
||||||
|
ANSIBLE_FILTER_PLUGINS: "../../filter_plugins"
|
||||||
|
config_options:
|
||||||
|
defaults:
|
||||||
|
deprecation_warnings: false
|
||||||
|
callback_whitelist: timer,profile_tasks
|
||||||
|
fact_caching: jsonfile
|
||||||
|
fact_caching_connection: ./cache
|
||||||
|
forks: 100
|
||||||
|
connection:
|
||||||
|
pipelining: true
|
||||||
|
playbooks:
|
||||||
|
converge: ../_shared/converge.yml
|
||||||
|
prepare: ../_shared/prepare.yml
|
||||||
|
verify: ../_shared/verify.yml
|
||||||
|
inventory:
|
||||||
|
links:
|
||||||
|
group_vars: ../_shared/group_vars
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
||||||
41
molecule/_shared/converge.yml
Normal file
41
molecule/_shared/converge.yml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Converge # noqa: role-name[path]
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
roles:
|
||||||
|
- ../../../
|
||||||
|
handlers:
|
||||||
|
- name: Reload nginx
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: nginx
|
||||||
|
state: reloaded
|
||||||
|
vars:
|
||||||
|
__nginx_conf: /etc/nginx/nginx.conf
|
||||||
|
post_tasks:
|
||||||
|
- name: TEMPLATE | Nginx site config
|
||||||
|
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
|
||||||
|
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)
|
||||||
|
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
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: nginx
|
||||||
|
state: started
|
||||||
36
molecule/_shared/group_vars/all/main.yml
Normal file
36
molecule/_shared/group_vars/all/main.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
vhost: 'test.local'
|
||||||
|
|
||||||
|
php_version: null
|
||||||
|
|
||||||
|
php_extra_packages:
|
||||||
|
- '{{ php_package_prefix }}pgsql'
|
||||||
|
|
||||||
|
php_install_xdebug: true
|
||||||
|
php_autoremove_default_pool: true
|
||||||
|
|
||||||
|
php_ini_fpm:
|
||||||
|
display_errors: 'Off'
|
||||||
|
|
||||||
|
php_ini_cli:
|
||||||
|
error_reporting: 'E_ALL'
|
||||||
|
|
||||||
|
php_fpm_poold:
|
||||||
|
- pool_name: 'test_ansible'
|
||||||
|
listen: '/run/php/php-ansible1.sock'
|
||||||
|
pm: 'dynamic'
|
||||||
|
pm_max_children: 250
|
||||||
|
pm_start_servers: 10
|
||||||
|
pm_min_spare_servers: 10
|
||||||
|
pm_max_spare_servers: 20
|
||||||
|
status_path: '/status'
|
||||||
|
ping_path: '/ping'
|
||||||
|
ping_response: 'ok'
|
||||||
|
|
||||||
|
- name: 'test_ansible2'
|
||||||
|
user: 'foo'
|
||||||
|
php_value:
|
||||||
|
display_errors: 'Off'
|
||||||
|
php_admin_value:
|
||||||
|
memory_limit: '98M'
|
||||||
41
molecule/_shared/prepare.yml
Normal file
41
molecule/_shared/prepare.yml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
- name: APT | Install packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
pkg: "{{ p }}"
|
||||||
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
|
vars:
|
||||||
|
p:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
- gpg
|
||||||
|
- lsb-release
|
||||||
|
- nginx
|
||||||
|
- vim
|
||||||
|
|
||||||
|
- name: BLOCK | Setup Sury on Debian
|
||||||
|
when:
|
||||||
|
- php_version is not none
|
||||||
|
- php_version != php_default_version
|
||||||
|
- ansible_distribution == 'Debian'
|
||||||
|
block:
|
||||||
|
- name: APT | Install Sury key
|
||||||
|
ansible.builtin.apt_key:
|
||||||
|
url: 'https://packages.sury.org/php/apt.gpg'
|
||||||
|
|
||||||
|
- name: APT_REPOSITORY | Add Sury repository
|
||||||
|
ansible.builtin.apt_repository:
|
||||||
|
repo: 'deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main'
|
||||||
|
|
||||||
|
- name: USER | Create PHP user
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: 'foo'
|
||||||
|
system: true
|
||||||
|
create_home: false
|
||||||
|
shell: '/usr/sbin/nologin'
|
||||||
4
molecule/_shared/requirements.yml
Normal file
4
molecule/_shared/requirements.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
collections:
|
||||||
|
- community.general
|
||||||
16
molecule/_shared/templates/custom_template.conf.j2
Normal file
16
molecule/_shared/templates/custom_template.conf.j2
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# {{ ansible_managed }} - custom template
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen 8888 http2;
|
||||||
|
listen 9999 http2 proxy_protocol;
|
||||||
|
server_name {{ item.name }};
|
||||||
|
|
||||||
|
index index.html index.htm;
|
||||||
|
|
||||||
|
root {{ item.root }};
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
45
molecule/_shared/templates/nginx.conf.j2
Normal file
45
molecule/_shared/templates/nginx.conf.j2
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
events {
|
||||||
|
worker_connections 512;
|
||||||
|
multi_accept on;
|
||||||
|
use epoll;
|
||||||
|
}
|
||||||
|
|
||||||
|
user www-data;
|
||||||
|
worker_processes 1;
|
||||||
|
pid /run/nginx.pid;
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
server {
|
||||||
|
server_name {{ vhost }};
|
||||||
|
|
||||||
|
root /var/www;
|
||||||
|
|
||||||
|
{% if ansible_local.hanxhx_php.fpm_pool.0.status_path is defined %}
|
||||||
|
location = {{ ansible_local.hanxhx_php.fpm_pool.0.status_path }} {
|
||||||
|
include fastcgi.conf;
|
||||||
|
fastcgi_pass unix:{{ ansible_local.hanxhx_php.fpm_pool.0.listen }};
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
{% if ansible_local.hanxhx_php.fpm_pool.0.ping_path is defined %}
|
||||||
|
location = {{ ansible_local.hanxhx_php.fpm_pool.0.ping_path }} {
|
||||||
|
include fastcgi.conf;
|
||||||
|
fastcgi_pass unix:{{ ansible_local.hanxhx_php.fpm_pool.0.listen }};
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
location = /ini.php {
|
||||||
|
include fastcgi.conf;
|
||||||
|
fastcgi_pass unix:{{ ansible_local.hanxhx_php.fpm_pool.1.listen }};
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
include fastcgi.conf;
|
||||||
|
fastcgi_pass unix:{{ ansible_local.hanxhx_php.fpm_pool.0.listen }};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
76
molecule/_shared/verify.yml
Normal file
76
molecule/_shared/verify.yml
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Verify
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
vars:
|
||||||
|
nginx_root: "/srv/www"
|
||||||
|
tasks:
|
||||||
|
- name: SHELL | Test php-cli
|
||||||
|
ansible.builtin.shell: set -o pipefail && php -i | grep '^PHP Version => {{ ansible_local.hanxhx_php.php_version }}' | head -n 1
|
||||||
|
changed_when: false
|
||||||
|
register: p
|
||||||
|
failed_when: p.stdout == ''
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
|
||||||
|
- name: FILE | Create /var/www
|
||||||
|
ansible.builtin.file:
|
||||||
|
dest: /var/www
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: COPY | Add phpinfo
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /var/www/phpinfo.php
|
||||||
|
content: '<?php phpinfo();'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: COPY | Add ini test file
|
||||||
|
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
|
||||||
|
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 {{ ansible_local.hanxhx_php.php_version }}' | sed -r 's/<//g'"
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
changed_when: false
|
||||||
|
register: c
|
||||||
|
failed_when: c.stdout == ''
|
||||||
|
|
||||||
|
- name: SHELL | Check custom php value # noqa: command-instead-of-module
|
||||||
|
ansible.builtin.shell: "curl -H 'Host: {{ vhost }}' http://127.0.0.1/ini.php 2> /dev/null"
|
||||||
|
changed_when: false
|
||||||
|
register: c
|
||||||
|
failed_when: 'php_fpm_poold.1.php_admin_value.memory_limit not in c.stdout'
|
||||||
|
|
||||||
|
- name: URI | Check ping
|
||||||
|
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
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
|
||||||
|
when: php_fpm_poold.0.status_path is defined
|
||||||
|
|
||||||
|
- 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'
|
||||||
13
molecule/debian-11/molecule.yml
Normal file
13
molecule/debian-11/molecule.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: debian-11
|
||||||
|
image: dokken/debian-11
|
||||||
|
command: /lib/systemd/systemd
|
||||||
|
dockerfile: ../_shared/Dockerfile.j2
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
privileged: true
|
||||||
13
molecule/debian-12/molecule.yml
Normal file
13
molecule/debian-12/molecule.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: debian-12
|
||||||
|
image: dokken/debian-12
|
||||||
|
command: /lib/systemd/systemd
|
||||||
|
dockerfile: ../_shared/Dockerfile.j2
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
privileged: true
|
||||||
13
molecule/debian-13/molecule.yml
Normal file
13
molecule/debian-13/molecule.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: debian-12
|
||||||
|
image: dokken/debian-13
|
||||||
|
command: /lib/systemd/systemd
|
||||||
|
dockerfile: ../_shared/Dockerfile.j2
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
privileged: true
|
||||||
0
molecule/default/.gitkeep
Normal file
0
molecule/default/.gitkeep
Normal file
13
molecule/ubuntu-20.04/molecule.yml
Normal file
13
molecule/ubuntu-20.04/molecule.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: ubuntu-20.04
|
||||||
|
image: dokken/ubuntu-20.04
|
||||||
|
command: /lib/systemd/systemd
|
||||||
|
dockerfile: ../_shared/Dockerfile.j2
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
privileged: true
|
||||||
13
molecule/ubuntu-22.04/molecule.yml
Normal file
13
molecule/ubuntu-22.04/molecule.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: ubuntu-22.04
|
||||||
|
image: dokken/ubuntu-22.04
|
||||||
|
command: /lib/systemd/systemd
|
||||||
|
dockerfile: ../_shared/Dockerfile.j2
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
privileged: true
|
||||||
13
molecule/ubuntu-24.04/molecule.yml
Normal file
13
molecule/ubuntu-24.04/molecule.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: ubuntu-24.04
|
||||||
|
image: dokken/ubuntu-24.04
|
||||||
|
command: /lib/systemd/systemd
|
||||||
|
dockerfile: ../_shared/Dockerfile.j2
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
privileged: true
|
||||||
49
requirements.txt
Normal file
49
requirements.txt
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
ansible==11.6.0
|
||||||
|
ansible-compat==25.5.0
|
||||||
|
ansible-core==2.18.6
|
||||||
|
ansible-lint==25.5.0
|
||||||
|
attrs==25.3.0
|
||||||
|
black==25.1.0
|
||||||
|
bracex==2.5.post1
|
||||||
|
certifi==2025.4.26
|
||||||
|
cffi==1.17.1
|
||||||
|
charset-normalizer==3.4.2
|
||||||
|
click==8.2.1
|
||||||
|
click-help-colors==0.9.4
|
||||||
|
cryptography==45.0.3
|
||||||
|
distro==1.9.0
|
||||||
|
docker==7.1.0
|
||||||
|
enrich==1.2.7
|
||||||
|
filelock==3.18.0
|
||||||
|
idna==3.10
|
||||||
|
importlib-metadata==8.7.0
|
||||||
|
jinja2==3.1.6
|
||||||
|
jsonschema==4.24.0
|
||||||
|
jsonschema-specifications==2025.4.1
|
||||||
|
markdown-it-py==3.0.0
|
||||||
|
markupsafe==3.0.2
|
||||||
|
mdurl==0.1.2
|
||||||
|
molecule==25.5.0
|
||||||
|
molecule-plugins==23.7.0
|
||||||
|
mypy-extensions==1.1.0
|
||||||
|
packaging==25.0
|
||||||
|
pathspec==0.12.1
|
||||||
|
platformdirs==4.3.8
|
||||||
|
pluggy==1.6.0
|
||||||
|
pycparser==2.22
|
||||||
|
pygments==2.19.1
|
||||||
|
pyyaml==6.0.2
|
||||||
|
referencing==0.36.2
|
||||||
|
requests==2.32.3
|
||||||
|
resolvelib==1.0.1
|
||||||
|
rich==14.0.0
|
||||||
|
rpds-py==0.25.1
|
||||||
|
ruamel-yaml==0.18.12
|
||||||
|
ruamel-yaml-clib==0.2.12
|
||||||
|
selinux==0.3.0
|
||||||
|
subprocess-tee==0.4.2
|
||||||
|
typing-extensions==4.13.2
|
||||||
|
urllib3==2.4.0
|
||||||
|
wcmatch==10.0
|
||||||
|
yamllint==1.37.1
|
||||||
|
zipp==3.22.0
|
||||||
4
requirements.yml
Normal file
4
requirements.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
collections:
|
||||||
|
- community.general
|
||||||
@@ -1,21 +1,36 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: APT | Install PHP-FPM
|
- name: APT | Install PHP-FPM for Debian based systems
|
||||||
apt: pkg={{ php_fpm_service }} state=latest
|
ansible.builtin.apt:
|
||||||
|
pkg: "{{ php_fpm_service }}"
|
||||||
|
state: "{{ 'present' if php_install_fpm else 'absent' }}"
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: LINEINFILE | PHP configuration
|
- name: LINEINFILE | PHP configuration
|
||||||
lineinfile: >
|
ansible.builtin.lineinfile:
|
||||||
dest='{{ php_etc_dir }}/fpm/php.ini'
|
dest: '{{ php_fpm_ini }}'
|
||||||
regexp='^;?{{ item.key }}'
|
regexp: '^;?{{ item.key }}'
|
||||||
line='{{ item.key }} = {{ item.value }}'
|
line: '{{ item.key }} = {{ item.value }}'
|
||||||
with_flattened:
|
create: true
|
||||||
- "{{ php_ini }}"
|
owner: root
|
||||||
- "{{ php_ini_fpm }}"
|
group: root
|
||||||
notify: restart php-fpm
|
mode: "0644"
|
||||||
|
loop: "{{ php_ini | combine(php_ini_fpm) | dict2items }}"
|
||||||
|
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_etc_dir }}/fpm/pool.d/{{ item.pool_name }}.conf'
|
dest: '{{ php_fpm_pool_dir }}/{{ item.name }}.conf'
|
||||||
with_items: "{{ php_fpm_poold }}"
|
owner: root
|
||||||
notify: restart php-fpm
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
loop: "{{ ansible_local.hanxhx_php.fpm_pool }}"
|
||||||
|
notify: Restart php-fpm
|
||||||
|
|
||||||
|
- name: FILE | Delete default pool if necessary
|
||||||
|
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'
|
||||||
|
notify: Restart php-fpm
|
||||||
|
|||||||
123
tasks/main.yml
123
tasks/main.yml
@@ -1,35 +1,110 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: ASSERT | Check variables
|
- name: SHELL | Check if we are in multiple PHP distribution
|
||||||
assert:
|
ansible.builtin.shell: set -o pipefail && apt-cache search php xdebug | grep 'php[[:digit:]].[[:digit:]]'
|
||||||
that: "php_version in php_managed_versions"
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
register: multiple_php
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: INCLUDE_VARS | Related to PHP version
|
- name: INCLUDE_VARS | Related to OS family
|
||||||
include_vars: "php-{{ php_version }}.yml"
|
ansible.builtin.include_vars: "OS_Family_{{ ansible_os_family }}.yml"
|
||||||
|
|
||||||
|
- name: INCLUDE_VARS | Related to OS version
|
||||||
|
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 | Prepare PHP version if not defined
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
php_version: "{{ php_default_version }}"
|
||||||
|
when: php_version is none or php_version == '' or php_version is not defined
|
||||||
|
|
||||||
|
- name: SET_FACT | Transform data
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
__php_fpm_full_pool: |
|
||||||
|
[
|
||||||
|
{% for p in php_fpm_poold %}
|
||||||
|
{
|
||||||
|
name: "{{ 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) }}",
|
||||||
|
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_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 %}
|
||||||
|
{% if k not in ['name', 'pool_name', 'listen', 'user', 'group', 'php_env', 'php_value', 'php_admin_value'] %}
|
||||||
|
{{ k }}: "{{ v }}"{% if not loop.last %},{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
}{% if not loop.last %},{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
|
||||||
|
- name: SET_FACT | To YAML
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
php_fpm_full_pool: "{{ __php_fpm_full_pool | from_yaml }}"
|
||||||
|
|
||||||
|
- name: FILE | Creates ansible facts.d
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/ansible/facts.d
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: COPY | Manage facts
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "{ \"fpm_pool\": {{ php_fpm_full_pool | to_nice_json }}, \"php_version\": \"{{ php_version }}\" }"
|
||||||
|
dest: /etc/ansible/facts.d/hanxhx_php.fact
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
register: f
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: SETUP | Gathers new facts
|
||||||
|
ansible.builtin.setup:
|
||||||
|
when: f.changed
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
- name: APT | Install PHP packages
|
- name: APT | Install PHP packages
|
||||||
apt: pkg={{ item }} state=latest update_cache=yes cache_valid_time=3600
|
ansible.builtin.apt:
|
||||||
with_flattened:
|
pkg: "{{ pkgs }}"
|
||||||
- "{{ php_packages }}"
|
state: present
|
||||||
- "{{ php_extra_packages }}"
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
|
install_recommends: false
|
||||||
|
vars:
|
||||||
|
pkgs: "{{ php_packages + php_extra_packages | flatten }}"
|
||||||
|
notify: Restart php-fpm
|
||||||
|
|
||||||
- name: INCLUDE | PHP-FPM
|
- name: IMPORT_TASKS | PHP-FPM
|
||||||
include: fpm.yml
|
ansible.builtin.import_tasks: fpm.yml
|
||||||
when: php_install_fpm
|
|
||||||
|
|
||||||
- name: LINEINFILE | PHP configuration
|
- name: LINEINFILE | PHP CLI configuration
|
||||||
lineinfile: >
|
ansible.builtin.lineinfile:
|
||||||
dest='{{ php_etc_dir }}/cli/php.ini'
|
dest: '{{ php_cli_ini }}'
|
||||||
regexp='^;?{{ item.key }}'
|
regexp: '^;?{{ item.key }}'
|
||||||
line='{{ item.key }} = {{ item.value }}'
|
line: '{{ item.key }} = {{ item.value }}'
|
||||||
with_flattened:
|
loop: "{{ php_ini | combine(php_ini_cli) | dict2items }}"
|
||||||
- "{{ php_ini }}"
|
|
||||||
- "{{ php_ini_cli }}"
|
|
||||||
|
|
||||||
- name: INCLUDE | Xdebug
|
- name: IMPORT_TASKS | Xdebug
|
||||||
include: xdebug.yml
|
ansible.builtin.import_tasks: xdebug.yml
|
||||||
when: php_install_xdebug
|
|
||||||
|
|
||||||
- name: APT | Install and configure opcache
|
- name: APT | Install and configure opcache
|
||||||
include: opcache.yml
|
ansible.builtin.import_tasks: opcache.yml
|
||||||
|
|
||||||
|
- name: SERVICE | Ensure PHP-FPM is started and enabled
|
||||||
|
when: php_install_fpm
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: '{{ php_fpm_service }}'
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|||||||
@@ -1,20 +1,29 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: APT | Install APCu
|
- name: APT | Install APCu
|
||||||
apt: pkg="{{ php_apt_prefix }}apcu" state=present
|
ansible.builtin.apt:
|
||||||
|
pkg: "{{ php_apcu_package }}"
|
||||||
|
install_recommends: false
|
||||||
|
|
||||||
- name: APT | Install Opcache
|
- name: APT | Install Opcache
|
||||||
apt: pkg="{{ php_apt_prefix }}opcache" state=present
|
ansible.builtin.apt:
|
||||||
when: php_version | version_compare('7.0', 'ge')
|
pkg: "{{ php_package_prefix }}opcache"
|
||||||
|
install_recommends: false
|
||||||
|
|
||||||
|
- name: TEMPLATE | Configure Opcache
|
||||||
|
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
|
- name: TEMPLATE | Configure APCu
|
||||||
template: >
|
ansible.builtin.template:
|
||||||
src=etc/__php__/mods-available/opcache.ini.j2
|
src: "etc/__php__/mods-available/apcu.ini.j2"
|
||||||
dest="{{ php_mods_dir }}/opcache.ini"
|
dest: "{{ php_mods_dir }}/apcu.ini"
|
||||||
notify: restart php-fpm
|
owner: root
|
||||||
|
group: root
|
||||||
- name: TEMPLATE | Configure APCu
|
mode: "0644"
|
||||||
template: >
|
notify: Restart php-fpm
|
||||||
src=etc/__php__/mods-available/apcu.ini.j2
|
|
||||||
dest={{ php_mods_dir }}/apcu.ini
|
|
||||||
notify: restart php-fpm
|
|
||||||
|
|||||||
@@ -1,21 +1,27 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: APT | Install php-xdebug
|
- name: BLOCK | Install Xdebug
|
||||||
apt: >
|
when: php_install_xdebug
|
||||||
pkg="{{ php_apt_prefix }}xdebug"
|
block:
|
||||||
state=latest
|
- name: APT | Install xdebug
|
||||||
update_cache=yes
|
ansible.builtin.apt:
|
||||||
cache_valid_time=3600
|
pkg: "{{ php_xdebug_package }}"
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
|
install_recommends: false
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: SHELL | Get Xdebug version
|
- name: TEMPLATE | Deploy module configurations
|
||||||
shell: dpkg -l | awk '$2 ~ /xdebug$/ { print $3 }'
|
ansible.builtin.template:
|
||||||
changed_when: false
|
src: "etc/__php__/mods-available/xdebug.ini.j2"
|
||||||
register: xdebug_version
|
dest: "{{ php_mods_dir }}/xdebug.ini"
|
||||||
|
owner: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Restart php-fpm
|
||||||
|
|
||||||
- name: TEMPLATE | Deploy module configurations
|
- name: APT | Uninstall xdebug
|
||||||
template: >
|
ansible.builtin.apt:
|
||||||
src=etc/__php__/mods-available/xdebug.ini.j2
|
pkg: "{{ php_xdebug_package }}"
|
||||||
dest={{ php_mods_dir }}/xdebug.ini
|
state: absent
|
||||||
owner=root
|
when: not php_install_xdebug
|
||||||
mode=0644
|
|
||||||
notify: restart php-fpm
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
; Start a new pool named '{{ item.pool_name }}'.
|
; Start a new pool named '{{ item.name }}'.
|
||||||
; the variable $pool can we used in any directive and will be replaced by the
|
; the variable $pool can we used in any directive and will be replaced by the
|
||||||
; pool name ('{{ item.pool_name }}' here)
|
; pool name ('{{ item.name }}' here)
|
||||||
[{{ item.pool_name }}]
|
[{{ item.name }}]
|
||||||
|
|
||||||
; Per pool prefix
|
; Per pool prefix
|
||||||
; It only applies on the following directives:
|
; It only applies on the following directives:
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
; Unix user/group of processes
|
; Unix user/group of processes
|
||||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||||
; will be used.
|
; will be used.
|
||||||
user = {{ item.user | default('www-data') }}
|
user = {{ item.user }}
|
||||||
group = {{ item.group | default('www-data') }}
|
group = {{ item.group }}
|
||||||
|
|
||||||
; The address on which to accept FastCGI requests.
|
; The address on which to accept FastCGI requests.
|
||||||
; Valid syntaxes are:
|
; Valid syntaxes are:
|
||||||
@@ -46,8 +46,8 @@ listen = {{ item.listen }}
|
|||||||
; BSD-derived systems allow connections regardless of permissions.
|
; BSD-derived systems allow connections regardless of permissions.
|
||||||
; Default Values: user and group are set as the running user
|
; Default Values: user and group are set as the running user
|
||||||
; mode is set to 0660
|
; mode is set to 0660
|
||||||
listen.owner = {{ item.listen_owner | default('www-data') }}
|
listen.owner = {{ item.listen_owner | default(php_default_user_group) }}
|
||||||
listen.group = {{ item.listen_owner | default('www-data') }}
|
listen.group = {{ item.listen_owner | default(php_default_user_group) }}
|
||||||
;listen.mode = 0660
|
;listen.mode = 0660
|
||||||
; When POSIX Access Control Lists are supported you can set them using
|
; When POSIX Access Control Lists are supported you can set them using
|
||||||
; these options, value is a comma separated list of user/group names.
|
; these options, value is a comma separated list of user/group names.
|
||||||
@@ -95,7 +95,7 @@ listen.group = {{ item.listen_owner | default('www-data') }}
|
|||||||
; pm.process_idle_timeout - The number of seconds after which
|
; pm.process_idle_timeout - The number of seconds after which
|
||||||
; an idle process will be killed.
|
; an idle process will be killed.
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
pm = {{ item.pm }}
|
pm = {{ item.pm | default('dynamic') }}
|
||||||
|
|
||||||
; The number of child processes to be created when pm is set to 'static' and the
|
; The number of child processes to be created when pm is set to 'static' and the
|
||||||
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
|
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
|
||||||
@@ -106,33 +106,33 @@ pm = {{ item.pm }}
|
|||||||
; forget to tweak pm.* to fit your needs.
|
; forget to tweak pm.* to fit your needs.
|
||||||
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
|
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
pm.max_children = {{ item.pm_max_children }}
|
pm.max_children = {{ item.pm_max_children | default('250') }}
|
||||||
|
|
||||||
; The number of child processes created on startup.
|
; The number of child processes created on startup.
|
||||||
; Note: Used only when pm is set to 'dynamic'
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
|
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
|
||||||
pm.start_servers = {{ item.pm_start_servers }}
|
pm.start_servers = {{ item.pm_start_servers | default('10') }}
|
||||||
|
|
||||||
; The desired minimum number of idle server processes.
|
; The desired minimum number of idle server processes.
|
||||||
; Note: Used only when pm is set to 'dynamic'
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
; Note: Mandatory when pm is set to 'dynamic'
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
pm.min_spare_servers = {{ item.pm_min_spare_servers }}
|
pm.min_spare_servers = {{ item.pm_min_spare_servers | default('10') }}
|
||||||
|
|
||||||
; The desired maximum number of idle server processes.
|
; The desired maximum number of idle server processes.
|
||||||
; Note: Used only when pm is set to 'dynamic'
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
; Note: Mandatory when pm is set to 'dynamic'
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
pm.max_spare_servers = {{ item.pm_max_spare_servers }}
|
pm.max_spare_servers = {{ item.pm_max_spare_servers | default('20') }}
|
||||||
|
|
||||||
; The number of seconds after which an idle process will be killed.
|
; The number of seconds after which an idle process will be killed.
|
||||||
; Note: Used only when pm is set to 'ondemand'
|
; Note: Used only when pm is set to 'ondemand'
|
||||||
; Default Value: 10s
|
; Default Value: 10s
|
||||||
;pm.process_idle_timeout = 10s;
|
pm.process_idle_timeout = {{ item.pm_process_idle_timeout | default('10s') }};
|
||||||
|
|
||||||
; The number of requests each child process should execute before respawning.
|
; The number of requests each child process should execute before respawning.
|
||||||
; 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:
|
||||||
@@ -231,7 +231,11 @@ pm.max_spare_servers = {{ item.pm_max_spare_servers }}
|
|||||||
; anything, but it may not be a good idea to use the .php extension or it
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
; may conflict with a real PHP file.
|
; may conflict with a real PHP file.
|
||||||
; Default Value: not set
|
; Default Value: not set
|
||||||
;pm.status_path = /status
|
{% if item.status_path is defined %}
|
||||||
|
pm.status_path = {{ item.status_path }}
|
||||||
|
{% else %}
|
||||||
|
;pm.status.path = /status
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||||
; URI will be recognized as a ping page. This could be used to test from outside
|
; URI will be recognized as a ping page. This could be used to test from outside
|
||||||
@@ -243,12 +247,20 @@ pm.max_spare_servers = {{ item.pm_max_spare_servers }}
|
|||||||
; anything, but it may not be a good idea to use the .php extension or it
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
; may conflict with a real PHP file.
|
; may conflict with a real PHP file.
|
||||||
; Default Value: not set
|
; Default Value: not set
|
||||||
|
{% if item.ping_path is defined %}
|
||||||
|
ping.path = {{ item.ping_path }}
|
||||||
|
{% else %}
|
||||||
;ping.path = /ping
|
;ping.path = /ping
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
; This directive may be used to customize the response of a ping request. The
|
; This directive may be used to customize the response of a ping request. The
|
||||||
; response is formatted as text/plain with a 200 response code.
|
; response is formatted as text/plain with a 200 response code.
|
||||||
; Default Value: pong
|
; Default Value: pong
|
||||||
|
{% if item.ping_response is defined %}
|
||||||
|
ping.response = {{ item.ping_response }}
|
||||||
|
{% else %}
|
||||||
;ping.response = pong
|
;ping.response = pong
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
; The access log file
|
; The access log file
|
||||||
; Default: not set
|
; Default: not set
|
||||||
@@ -357,7 +369,7 @@ chdir = /
|
|||||||
; Note: on highloaded environement, this can cause some delay in the page
|
; Note: on highloaded environement, this can cause some delay in the page
|
||||||
; process time (several ms).
|
; process time (several ms).
|
||||||
; Default Value: no
|
; Default Value: no
|
||||||
;catch_workers_output = yes
|
catch_workers_output = {{ item.catch_workers_output | default('no') }}
|
||||||
|
|
||||||
; Clear environment in FPM workers
|
; Clear environment in FPM workers
|
||||||
; Prevents arbitrary environment variables from reaching FPM worker processes
|
; Prevents arbitrary environment variables from reaching FPM worker processes
|
||||||
@@ -409,5 +421,19 @@ chdir = /
|
|||||||
;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
|
||||||
|
{% if item.php_env is defined %}
|
||||||
|
{% for k, v in item.php_env.items() | list %}
|
||||||
|
env[{{ k }}] = {{ v }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if item.php_value is defined %}
|
||||||
|
{% for k, v in item.php_value.items() | list %}
|
||||||
|
php_value[{{ k }}] = {{ v }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if item.php_admin_value is defined %}
|
||||||
|
{% for k, v in item.php_admin_value.items() | list %}
|
||||||
|
php_admin_value[{{ k }}] = {{ v }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
; vim:filetype=dosini
|
; vim:filetype=dosini
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
;
|
|
||||||
; {{ ansible_managed }}
|
|
||||||
;
|
|
||||||
|
|
||||||
extension=apcu.so
|
extension=apcu.so
|
||||||
|
|
||||||
; apc.enabled can be set to 0 to disable APC
|
; apc.enabled can be set to 0 to disable APC
|
||||||
@@ -23,3 +19,7 @@ apc.file_update_protection={{ php_apc_file_update_protection }}
|
|||||||
apc.slam_defense={{ php_apc_slam_defense }}
|
apc.slam_defense={{ php_apc_slam_defense }}
|
||||||
; Verification with ctime will avoid problems caused by programs such as svn or rsync by making sure inodes haven't changed since the last stat
|
; Verification with ctime will avoid problems caused by programs such as svn or rsync by making sure inodes haven't changed since the last stat
|
||||||
apc.stat_ctime={{ php_apc_stat_ctime }}
|
apc.stat_ctime={{ php_apc_stat_ctime }}
|
||||||
|
|
||||||
|
;
|
||||||
|
; {{ ansible_managed }}
|
||||||
|
;
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
;
|
|
||||||
; {{ ansible_managed }}
|
|
||||||
;
|
|
||||||
|
|
||||||
; configuration for php ZendOpcache module
|
; configuration for php ZendOpcache module
|
||||||
; priority=05
|
; priority=05
|
||||||
zend_extension=opcache.so
|
zend_extension=opcache.so
|
||||||
@@ -15,3 +11,7 @@ opcache.max_wasted_percentage={{ php_opcache_max_wasted_percentage }}
|
|||||||
opcache.validate_timestamps={{ php_opcache_validate_timestamps }}
|
opcache.validate_timestamps={{ php_opcache_validate_timestamps }}
|
||||||
opcache.revalidate_freq={{ php_opcache_revalidate_freq }}
|
opcache.revalidate_freq={{ php_opcache_revalidate_freq }}
|
||||||
opcache.max_file_size={{ php_opcache_max_file_size }}
|
opcache.max_file_size={{ php_opcache_max_file_size }}
|
||||||
|
|
||||||
|
;
|
||||||
|
; {{ ansible_managed }}
|
||||||
|
;
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
; --------------------------------------
|
|
||||||
; {{ ansible_managed }}
|
|
||||||
; --------------------------------------
|
|
||||||
|
|
||||||
; configuration for php xdebug module
|
; configuration for php xdebug module
|
||||||
; priority=20
|
; priority=20
|
||||||
zend_extension=xdebug.so
|
zend_extension=xdebug.so
|
||||||
|
|
||||||
{% if xdebug_version.stdout|version_compare('2.3', 'gt') %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
xdebug_auto_trace={{ php_xdebug_auto_trace }}
|
xdebug_auto_trace={{ php_xdebug_auto_trace }}
|
||||||
xdebug_cli_color={{ php_xdebug_cli_color }}
|
xdebug_cli_color={{ php_xdebug_cli_color }}
|
||||||
xdebug_collect_assignments={{ php_xdebug_collect_assignments }}
|
xdebug_collect_assignments={{ php_xdebug_collect_assignments }}
|
||||||
@@ -33,9 +26,7 @@ xdebug_overload_var_dump={{ php_xdebug_overload_var_dump }}
|
|||||||
xdebug_profiler_append={{ php_xdebug_profiler_append }}
|
xdebug_profiler_append={{ php_xdebug_profiler_append }}
|
||||||
xdebug_profiler_enable={{ php_xdebug_profiler_enable }}
|
xdebug_profiler_enable={{ php_xdebug_profiler_enable }}
|
||||||
xdebug_profiler_enable_trigger={{ php_xdebug_profiler_enable_trigger }}
|
xdebug_profiler_enable_trigger={{ php_xdebug_profiler_enable_trigger }}
|
||||||
{% if xdebug_version.stdout|version_compare('2.3', 'gt') %}
|
|
||||||
xdebug_profiler_enable_trigger_value={{ php_xdebug_profiler_enable_trigger_value }}
|
xdebug_profiler_enable_trigger_value={{ php_xdebug_profiler_enable_trigger_value }}
|
||||||
{% endif %}
|
|
||||||
xdebug_profiler_output_dir={{ php_xdebug_profiler_output_dir }}
|
xdebug_profiler_output_dir={{ php_xdebug_profiler_output_dir }}
|
||||||
xdebug_profiler_output_name={{ php_xdebug_profiler_output_name }}
|
xdebug_profiler_output_name={{ php_xdebug_profiler_output_name }}
|
||||||
xdebug_remote_autostart={{ php_xdebug_remote_autostart }}
|
xdebug_remote_autostart={{ php_xdebug_remote_autostart }}
|
||||||
@@ -52,9 +43,7 @@ xdebug_show_exception_trace={{ php_xdebug_show_exception_trace }}
|
|||||||
xdebug_show_local_vars={{ php_xdebug_show_local_vars }}
|
xdebug_show_local_vars={{ php_xdebug_show_local_vars }}
|
||||||
xdebug_show_mem_delta={{ php_xdebug_show_mem_delta }}
|
xdebug_show_mem_delta={{ php_xdebug_show_mem_delta }}
|
||||||
xdebug_trace_enable_trigger={{ php_xdebug_trace_enable_trigger }}
|
xdebug_trace_enable_trigger={{ php_xdebug_trace_enable_trigger }}
|
||||||
{% if xdebug_version.stdout|version_compare('2.3', 'gt') %}
|
|
||||||
xdebug_trace_enable_trigger_value={{ php_xdebug_trace_enable_trigger_value }}
|
xdebug_trace_enable_trigger_value={{ php_xdebug_trace_enable_trigger_value }}
|
||||||
{% endif %}
|
|
||||||
xdebug_trace_format={{ php_xdebug_trace_format }}
|
xdebug_trace_format={{ php_xdebug_trace_format }}
|
||||||
xdebug_trace_options={{ php_xdebug_trace_options }}
|
xdebug_trace_options={{ php_xdebug_trace_options }}
|
||||||
xdebug_trace_output_dir={{ php_xdebug_trace_output_dir }}
|
xdebug_trace_output_dir={{ php_xdebug_trace_output_dir }}
|
||||||
@@ -63,3 +52,6 @@ xdebug_var_display_max_children={{ php_xdebug_var_display_max_children }}
|
|||||||
xdebug_var_display_max_data={{ php_xdebug_var_display_max_data }}
|
xdebug_var_display_max_data={{ php_xdebug_var_display_max_data }}
|
||||||
xdebug_var_display_max_depth={{ php_xdebug_var_display_max_depth }}
|
xdebug_var_display_max_depth={{ php_xdebug_var_display_max_depth }}
|
||||||
|
|
||||||
|
; --------------------------------------
|
||||||
|
; {{ ansible_managed }}
|
||||||
|
; --------------------------------------
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM williamyeh/ansible:debian8-onbuild
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
CMD ["sh", "tests/test.sh", "5.6"]
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM williamyeh/ansible:debian8-onbuild
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
CMD ["sh", "tests/test.sh", "7.0"]
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
php_version: '5.6'
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
php_version: '7.0'
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
localhost
|
|
||||||
|
|
||||||
[php-5.6]
|
|
||||||
localhost
|
|
||||||
|
|
||||||
[php-7.0]
|
|
||||||
localhost
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
|
|
||||||
|
|
||||||
DIR=$( dirname $0 )
|
|
||||||
PLAYBOOK="$DIR/test.yml"
|
|
||||||
ANSIBLE_ARG="localhost"
|
|
||||||
|
|
||||||
set -ev
|
|
||||||
|
|
||||||
ansible --version
|
|
||||||
|
|
||||||
# Check syntax
|
|
||||||
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
|
|
||||||
|
|
||||||
# Check role
|
|
||||||
ansible-playbook -i localhost, -c local -e "php_version=$1" --become -vv $PLAYBOOK
|
|
||||||
|
|
||||||
# Check indempotence
|
|
||||||
ansible-playbook -i localhost, -c local -e "php_version=$1" --become -vv $PLAYBOOK \
|
|
||||||
| grep -q 'changed=0.*failed=0' \
|
|
||||||
&& (echo 'Idempotence test: pass' && exit 0) \
|
|
||||||
|| (echo 'Idempotence test: fail' && exit 1)
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
- hosts: all
|
|
||||||
vars:
|
|
||||||
vhost: 'test.local'
|
|
||||||
php_extra_packages:
|
|
||||||
- '{{ php_apt_prefix }}recode'
|
|
||||||
php_install_xdebug: true
|
|
||||||
pre_tasks:
|
|
||||||
- name: APT | Install DotDeb key
|
|
||||||
apt_key: url='http://www.dotdeb.org/dotdeb.gpg' state=present
|
|
||||||
when: >
|
|
||||||
ansible_distribution_major_version | version_compare(8, 'eq') and
|
|
||||||
php_version | version_compare('7.0', 'ge')
|
|
||||||
- name: APT | Add Dotdeb repository for Jessie + PHP7
|
|
||||||
apt_repository: repo='deb http://packages.dotdeb.org jessie all' state=present
|
|
||||||
when: >
|
|
||||||
ansible_distribution_major_version | version_compare(8, 'eq') and
|
|
||||||
php_version | version_compare('7.0', 'ge')
|
|
||||||
- name: APT | Install nginx
|
|
||||||
apt: pkg=nginx state=present update_cache=yes cache_valid_time=3600
|
|
||||||
- name: SHELL | Get nginx version
|
|
||||||
shell: nginx -V 2>&1 | awk -F '/' '/nginx version/ { print $2 }'
|
|
||||||
register: nginx_version
|
|
||||||
changed_when: false
|
|
||||||
- set_fact: nginx_include="fastcgi_params"
|
|
||||||
when: nginx_version.stdout | version_compare('1.6', '<', true)
|
|
||||||
- set_fact: nginx_include="fastcgi.conf"
|
|
||||||
when: nginx_version.stdout | version_compare('1.6', '>=', true)
|
|
||||||
tasks:
|
|
||||||
- name: COPY | Vhost
|
|
||||||
copy: >
|
|
||||||
dest=/etc/nginx/sites-enabled/{{ vhost }}
|
|
||||||
content='server { server_name {{ vhost }}; root /var/www; location ~ \.php$ { include {{ nginx_include }}; fastcgi_pass unix:{{ php_default_fpm_sock }}; } }'
|
|
||||||
notify: reload nginx
|
|
||||||
handlers:
|
|
||||||
- name: reload nginx
|
|
||||||
service: name=nginx state=reloaded
|
|
||||||
roles:
|
|
||||||
- ../../
|
|
||||||
post_tasks:
|
|
||||||
- name: SHELL | Test php-cli
|
|
||||||
shell: php -i | grep '^PHP Version' | head -n 1
|
|
||||||
changed_when: false
|
|
||||||
register: p
|
|
||||||
failed_when: p.stdout == ''
|
|
||||||
- name: FILE | Create /var/www
|
|
||||||
file: dest=/var/www state=directory
|
|
||||||
- name: COPY | Add phpinfo
|
|
||||||
copy: dest=/var/www/phpinfo.php content='<?php phpinfo();'
|
|
||||||
- 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 [57].*<' | sed -r 's/<//g'"
|
|
||||||
changed_when: false
|
|
||||||
register: c
|
|
||||||
failed_when: c.stdout == ''
|
|
||||||
3
vars/Debian-bookworm.yml
Normal file
3
vars/Debian-bookworm.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
php_default_version: '8.2'
|
||||||
3
vars/Debian-bullseye.yml
Normal file
3
vars/Debian-bullseye.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
php_default_version: '7.4'
|
||||||
3
vars/Debian-trixie.yml
Normal file
3
vars/Debian-trixie.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
php_default_version: '8.4'
|
||||||
24
vars/OS_Family_Debian.yml
Normal file
24
vars/OS_Family_Debian.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
php_packages:
|
||||||
|
- '{{ php_package_prefix }}cli'
|
||||||
|
- '{{ php_package_prefix }}curl'
|
||||||
|
- '{{ php_package_prefix }}gd'
|
||||||
|
- '{{ php_package_prefix }}mysql'
|
||||||
|
- '{{ php_package_prefix }}intl'
|
||||||
|
|
||||||
|
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_mods_dir: '/etc/php/{{ php_version }}/mods-available'
|
||||||
|
php_fpm_pool_dir: '/etc/php/{{ php_version }}/fpm/pool.d'
|
||||||
|
|
||||||
|
php_fpm_service: 'php{{ php_version }}-fpm'
|
||||||
|
php_default_fpm_sock: '/var/run/php/php{{ php_version }}-fpm.sock'
|
||||||
|
|
||||||
|
php_cli_ini: '/etc/php/{{ php_version }}/cli/php.ini'
|
||||||
|
php_fpm_ini: '/etc/php/{{ php_version }}/fpm/php.ini'
|
||||||
|
|
||||||
|
php_default_user_group: 'www-data'
|
||||||
3
vars/Ubuntu-focal.yml
Normal file
3
vars/Ubuntu-focal.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
php_default_version: '7.4'
|
||||||
3
vars/Ubuntu-jammy.yml
Normal file
3
vars/Ubuntu-jammy.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
php_default_version: '8.1'
|
||||||
3
vars/Ubuntu-noble.yml
Normal file
3
vars/Ubuntu-noble.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
php_default_version: '8.3'
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
php_packages:
|
|
||||||
- '{{ php_apt_prefix }}cli'
|
|
||||||
- '{{ php_apt_prefix }}curl'
|
|
||||||
- '{{ php_apt_prefix }}gd'
|
|
||||||
- '{{ php_apt_prefix }}mcrypt'
|
|
||||||
- '{{ php_mysql_package }}'
|
|
||||||
- '{{ php_apt_prefix }}intl'
|
|
||||||
|
|
||||||
php_managed_versions:
|
|
||||||
- '5.6'
|
|
||||||
- '7.0'
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
php_apt_prefix: 'php5-'
|
|
||||||
php_etc_dir: '/etc/php5'
|
|
||||||
php_fpm_service: 'php5-fpm'
|
|
||||||
php_default_fpm_sock: '/var/run/php5-fpm.sock'
|
|
||||||
php_mods_dir: '/etc/php5/mods-available'
|
|
||||||
php_mysql_package: 'php5-mysqlnd'
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
php_apt_prefix: 'php7.0-'
|
|
||||||
php_etc_dir: '/etc/php/7.0'
|
|
||||||
php_fpm_service: 'php7.0-fpm'
|
|
||||||
php_default_fpm_sock: '/var/run/php/php7.0-fpm.sock'
|
|
||||||
php_mods_dir: '/etc/php/mods-available'
|
|
||||||
php_mysql_package: 'php7.0-mysql'
|
|
||||||
Reference in New Issue
Block a user