Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Update PHP role to latest version.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed May 21, 2021
1 parent 20b7654 commit df60dd1
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 95 deletions.
2 changes: 1 addition & 1 deletion provisioning/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ roles:
- name: geerlingguy.nodejs
version: 5.1.1
- name: geerlingguy.php
version: 4.5.1
version: 4.6.1
- name: geerlingguy.php-memcached
version: 2.0.2
- name: geerlingguy.php-mysql
Expand Down
8 changes: 4 additions & 4 deletions provisioning/roles/geerlingguy.php/.ansible-lint
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_list:
- '306'
- '405'
- '503'
- '106'
- 'yaml'
- 'risky-shell-pipe'
- 'no-handler'
- 'role-name'
80 changes: 80 additions & 0 deletions provisioning/roles/geerlingguy.php/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
name: CI
'on':
pull_request:
push:
branches:
- master
schedule:
- cron: "0 4 * * 4"

defaults:
run:
working-directory: 'geerlingguy.php'

jobs:

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.php'

- 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 .
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
include:
- distro: centos8
playbook: converge.yml
- distro: centos7
playbook: converge.yml
- distro: ubuntu2004
playbook: converge.yml
- distro: ubuntu1804
playbook: converge.yml
- distro: debian10
playbook: converge.yml
- distro: debian9
playbook: converge.yml

- distro: centos7
playbook: source-install.yml

steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.php'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install ansible molecule[docker] docker

- name: Run Molecule tests.
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
MOLECULE_PLAYBOOK: ${{ matrix.playbook }}
38 changes: 38 additions & 0 deletions provisioning/roles/geerlingguy.php/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# This workflow requires a GALAXY_API_KEY secret present in the GitHub
# repository or organization.
#
# See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy
# See: https://github.com/ansible/galaxy/issues/46

name: Release
'on':
push:
tags:
- '*'

defaults:
run:
working-directory: 'geerlingguy.php'

jobs:

release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.php'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install Ansible.
run: pip3 install ansible-base

- name: Trigger a new import on Galaxy.
run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)
2 changes: 2 additions & 0 deletions provisioning/roles/geerlingguy.php/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.retry
*/__pycache__
*.pyc
.cache

38 changes: 0 additions & 38 deletions provisioning/roles/geerlingguy.php/.travis.yml

This file was deleted.

24 changes: 16 additions & 8 deletions provisioning/roles/geerlingguy.php/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ansible Role: PHP

[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-php.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-php)
[![CI](https://github.com/geerlingguy/ansible-role-php/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-php/actions?query=workflow%3ACI)

Installs PHP on RedHat/CentOS and Debian/Ubuntu servers.

Expand Down Expand Up @@ -71,14 +71,22 @@ Control over the fpm daemon's state; set these to `stopped` and `false` if you w

The handler restarts PHP-FPM by default. Setting the value to `reloaded` will reload the service, intead of restarting it.

php_fpm_listen: "127.0.0.1:9000"
php_fpm_listen_allowed_clients: "127.0.0.1"
php_fpm_pm_max_children: 50
php_fpm_pm_start_servers: 5
php_fpm_pm_min_spare_servers: 5
php_fpm_pm_max_spare_servers: 5

Specific settings inside the default `www.conf` PHP-FPM pool. If you'd like to manage additional settings, you can do so either by replacing the file with your own template or using `lineinfile` like this role does inside `tasks/configure-fpm.yml`.
php_fpm_pools:
- pool_name: www
pool_template: www.conf.j2
pool_listen: "127.0.0.1:9000"
pool_listen_allowed_clients: "127.0.0.1"
pool_pm: dynamic
pool_pm_max_children: 5
pool_pm_start_servers: 2
pool_pm_min_spare_servers: 1
pool_pm_max_spare_servers: 3
pool_pm_max_requests: 500

List of PHP-FPM pool to create. By default, www pool is created. To setup a new pool, add an item to php_fpm_pools list.

Specific settings inside the default `www.conf.j2` PHP-FPM pool. If you'd like to manage additional settings, you can do so either by replacing the file with your own template using `pool_template`.

### php.ini settings

Expand Down
14 changes: 14 additions & 0 deletions provisioning/roles/geerlingguy.php/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ php_fpm_pm_max_children: 50
php_fpm_pm_start_servers: 5
php_fpm_pm_min_spare_servers: 5
php_fpm_pm_max_spare_servers: 5
php_fpm_pm_max_requests: 0

# PHP-FPM pool configuration.
php_fpm_pools:
- pool_name: www
pool_template: www.conf.j2
pool_listen: "{{ php_fpm_listen }}"
pool_listen_allowed_clients: "{{ php_fpm_listen_allowed_clients }}"
pool_pm: dynamic
pool_pm_max_children: "{{ php_fpm_pm_max_children }}"
pool_pm_start_servers: "{{ php_fpm_pm_start_servers }}"
pool_pm_min_spare_servers: "{{ php_fpm_pm_min_spare_servers }}"
pool_pm_max_spare_servers: "{{ php_fpm_pm_max_spare_servers }}"
pool_php_fpm_pm_max_requests: "{{ php_fpm_pm_max_requests }}"

# The executable to run when calling PHP from the command line.
php_executable: "php"
Expand Down
1 change: 0 additions & 1 deletion provisioning/roles/geerlingguy.php/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ galaxy_info:
platforms:
- name: EL
versions:
- 6
- 7
- 8
- name: Fedora
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ dependency:
name: galaxy
driver:
name: docker
lint: |
set -e
yamllint .
ansible-lint
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
Expand Down
35 changes: 5 additions & 30 deletions provisioning/roles/geerlingguy.php/tasks/configure-fpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,15 @@
mode: 0755
when: php_fpm_pool_conf_path_dir_stat.stat.islnk is not defined

- name: Ensure the default pool exists.
- name: Create fpm pools.
template:
src: www.conf.j2
dest: "{{ php_fpm_pool_conf_path }}"
src: "{{ item.pool_template | default('www.conf.j2', true) }}"
dest: "{{ php_fpm_pool_conf_path | dirname }}/{{ item.pool_name }}.conf"
owner: root
group: root
mode: 0644
force: false
when: php_enable_php_fpm

- name: Configure php-fpm pool (if enabled).
lineinfile:
dest: "{{ php_fpm_pool_conf_path }}"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
mode: 0644
with_items:
- regexp: "^user.?=.+$"
line: "user = {{ php_fpm_pool_user }}"
- regexp: "^group.?=.+$"
line: "group = {{ php_fpm_pool_group }}"
- regexp: "^listen.?=.+$"
line: "listen = {{ php_fpm_listen }}"
- regexp: '^listen\.allowed_clients.?=.+$'
line: "listen.allowed_clients = {{ php_fpm_listen_allowed_clients }}"
- regexp: '^pm\.max_children.?=.+$'
line: "pm.max_children = {{ php_fpm_pm_max_children }}"
- regexp: '^pm\.start_servers.?=.+$'
line: "pm.start_servers = {{ php_fpm_pm_start_servers }}"
- regexp: '^pm\.min_spare_servers.?=.+$'
line: "pm.min_spare_servers = {{ php_fpm_pm_min_spare_servers }}"
- regexp: '^pm\.max_spare_servers.?=.+$'
line: "pm.max_spare_servers = {{ php_fpm_pm_max_spare_servers }}"
force: true
loop: "{{ php_fpm_pools | default([], true) }}"
when: php_enable_php_fpm
notify: restart php-fpm

Expand Down
20 changes: 11 additions & 9 deletions provisioning/roles/geerlingguy.php/templates/www.conf.j2
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
[www]
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
; {{ ansible_managed }}

[{{ item.pool_name | mandatory }}]
listen = {{ item.pool_listen | mandatory }}
listen.allowed_clients = {{ item.pool_listen_allowed_clients | default('127.0.0.1', true) }}
user = {{ php_fpm_pool_user }}
group = {{ php_fpm_pool_group }}

listen.owner = {{ php_fpm_pool_user }}
listen.group = {{ php_fpm_pool_group }}

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 5
pm.max_requests = 500
pm = {{ item.pool_pm | default('dynamic', true) }}
pm.max_children = {{ item.pool_pm_max_children | default(50, true) }}
pm.start_servers = {{ item.pool_pm_start_servers | default(5, true) }}
pm.min_spare_servers = {{ item.pool_pm_min_spare_servers | default(5, true) }}
pm.max_spare_servers = {{ item.pool_pm_max_spare_servers | default(5, true) }}
pm.max_requests = {{ item.pool_pm_max_requests | default(500, true) }}

0 comments on commit df60dd1

Please sign in to comment.