initial commit

This commit is contained in:
2021-10-18 18:03:37 +02:00
commit ddb3a9c856
11 changed files with 209 additions and 0 deletions

58
README.md Normal file
View File

@@ -0,0 +1,58 @@
Role Name
=========
Install php-fpm (for apache)
and some php packages along the way
Requirements
------------
None
Role Variables
--------------
php_version: default 73
php_fpm_pool_user: default apache
php_fpm_pool_group: default apache
php_fpm_listen_url: default 127.0.0.1:90{{ php_version }}
php_pm: static
php_pm_max_children: 1000
php_pm_max_requests: 10000
php_pm_status_url: /phpstatus
php_packages: [ 'php{{ php_version }}-php-common' ]
Dependencies
------------
Better have apache
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
vars:
httpd_server_name: foobar.fr
php_version: 73
php_packages:
- php73-php-imap
- php73-php-pear
roles:
- apache
- php-fpm
License
-------
BSD
Author Information
------------------
Thomas C <thomas@opendoor.fr>

11
defaults/main.yml Normal file
View File

@@ -0,0 +1,11 @@
---
# defaults file for php-fpm
php_version: 73
php_fpm_pool_user: apache
php_fpm_pool_group: apache
php_fpm_listen_url: 127.0.0.1:90{{ php_version }}
php_pm: static
php_pm_max_children: 1000
php_pm_max_requests: 10000
php_pm_status_url: /phpstatus
php_packages: [ 'php{{ php_version }}-php-common' ]

6
handlers/main.yml Normal file
View File

@@ -0,0 +1,6 @@
---
# handlers file for php-fpm
- name: restart php-fpm
service:
name: php-fpm
state: restarted

53
meta/main.yml Normal file
View File

@@ -0,0 +1,53 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.9
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

4
tasks/main.yml Normal file
View File

@@ -0,0 +1,4 @@
---
# tasks file for php-fpm
- include_tasks: php-fpm.yml
tags: php

45
tasks/php-fpm.yml Normal file
View File

@@ -0,0 +1,45 @@
---
# tasks file for php-fpm
- name: install repository definitions
yum:
name:
- epel-release
- http://rpms.remirepo.net/enterprise/remi-release-{{ ansible_distribution_major_version }}.rpm
- yum-utils
state: present
- name: activate given repo
ini_file:
path: /etc/yum.repos.d/remi-php{{ php_version }}.repo
section: "remi-php{{ php_version }}"
option: enabled
value: 1
- name: install php-fpm
yum:
name:
- php{{php_version}}-php-fpm
state: installed
- name: install php packages
yum:
name: "{{ php_packages }}"
state: present
- name: configure php-fpm pool 2
template:
src: www.conf
dest: /etc/opt/remi/php{{ php_version }}/php-fpm.d/www_{{ php_version }}.conf
notify: restart php-fpm
- name: create log symlink
file:
src: /var/opt/remi/php{{ php_version }}/log/php-fpm
dest: /var/log/php-fpm
state: link
- name: start and enable service
service:
name: php{{php_version}}-php-fpm
enabled: yes
state: started

View File

@@ -0,0 +1,3 @@
<FilesMatch \.php$>
SetHandler proxy:fcgi://{{ php_fpm_listen_url }}
</FilesMatch>

20
templates/www.conf Normal file
View File

@@ -0,0 +1,20 @@
[www{{php_version}}]
user = {{ php_fpm_pool_user }}
group = {{ php_fpm_pool_group }}
listen = {{ php_fpm_listen_url }}
listen.backlog = 511
pm = {{ php_pm }}
pm.max_children = {{ php_pm_max_children }}
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = {{ php_pm_max_requests }}
pm.status_path = {{ php_pm_status_url }}
ping.path = /ping
access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
access.log = /var/opt/remi/php{{ php_version }}/log/php-fpm/$pool.access.log
slowlog = /var/opt/remi/php{{ php_version }}/log/php-fpm/$pool.slow.log
request_slowlog_timeout = 5s
php_value[session.save_handler] = files
php_value[session.save_path] = /var/opt/remi/php{{ php_version }}/lib/php/se
php_value[soap.wsdl_cache_dir] = /var/opt/remi/php{{ php_version }}/lib/php/ws

2
tests/inventory Normal file
View File

@@ -0,0 +1,2 @@
localhost

5
tests/test.yml Normal file
View File

@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- php-fpm

2
vars/main.yml Normal file
View File

@@ -0,0 +1,2 @@
---
# vars file for php-fpm