Merge pull request 'Merging Staging to Main' (#10) from staging into main

Reviewed-on: #10
Reviewed-by: meaz <meaz@no-reply@disroot.org>
This commit is contained in:
muppeth 2024-08-02 10:21:16 +02:00
commit 4528d0f88b
5 changed files with 63 additions and 9 deletions

View file

@ -1,9 +1,41 @@
# PHP-FPM - Ansible Role # PHP-FPM - Ansible Role
This role covers deployment, configuration and software updates of php-fpm. This role is released under MIT Licence and we give no warranty for this piece of software. Currently supported OS - Debian. Role covers deployment, configuration and software updates of php-fpm and php-modules.
This role is released under MIT Licence and we give no warranty for this piece of software.
Currently supported OS - Debian. PHP repository used in the role is coming from: https://packages.sury.org/php/
## TODO
- obviously better Readme file ## Variables, versions and modules
`defaults/main.yml` provides example variables that can be used with the role. To modify any of the settings, specify appropriate variables in your `host_vars` file.
To specify php-fpm version, copy and edit `php_version` in your host_vars file.
To install php modules, specify packages under `php_pkgs` array. For example:
```
php_pkgs:
- php{{ php_version }}-fpm
- php{{ php_version }}-bz2
- php{{ php_version }}-cgi
- php{{ php_version }}-cli
- php{{ php_version }}-common
- php{{ php_version }}-curl
- php{{ php_version }}-dev
- php{{ php_version }}-enchant
- php{{ php_version }}-gd
- php{{ php_version }}-gmp
- php{{ php_version }}-igbinary
- php{{ php_version }}-interbase
- php{{ php_version }}-intl
- php{{ php_version }}-mbstring
- php{{ php_version }}-msgpack
- php{{ php_version }}-pspell
- php{{ php_version }}-readline
- php{{ php_version }}-zip
```
## Supported versions and cleanup
Supported versions of php-fpm:
- 8.2 (default)
- 8.1
- 8.0
**Note!**
Role assumes only one version of php should be installed on the host and so it will remove all packages and configuration files other than `{{php_version }}`.

18
tasks/cleanup.yml Normal file
View file

@ -0,0 +1,18 @@
---
- name: '[CLEANUP] - Remove unused php-fpm versions and their modules'
shell: apt remove --purge $(dpkg -l | grep php | grep -v php- | grep -v {{ php_version }} | awk '{print $2}') -y
- name: '[CLEANUP] - Check for unused php configursation directories'
find:
paths: /etc/php/
file_type: 'directory'
excludes:
- '{{ php_version }}'
register: 'php_old_config_versions'
- name: '[CLEANUP] - Remove unused php configuration directories'
file:
path: '/etc/php/{{ item }}'
state: absent
with_items: '{{ php_old_config_versions }}'

View file

@ -28,3 +28,4 @@
alternatives: alternatives:
name: 'php' name: 'php'
path: '/usr/bin/php{{ php_version }}' path: '/usr/bin/php{{ php_version }}'

View file

@ -21,3 +21,4 @@
notify: notify:
- Restart php-fpm - Restart php-fpm
- Restart nginx - Restart nginx

View file

@ -1,9 +1,11 @@
--- ---
- name: INCLUDE | Install - include_tasks: install.yml
include_tasks: install.yml
when: install_php == 'true' when: install_php == 'true'
- name: INCLUDE | Install - include_tasks: configure.yml
include_tasks: configure.yml
when: install_php == 'true' when: install_php == 'true'
- include_tasks: 'cleanup.yml'
when: install_php == 'true'