Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mjmeijerman committed Dec 30, 2024
1 parent 265263c commit 18f7ba0
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 61 deletions.
56 changes: 27 additions & 29 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,48 @@

php8_version: 8.0

php8_enable_apache: no
php8_enable_cgi: no
php8_enable_fpm: no
php8_enable_apache: false
php8_enable_cgi: false
php8_enable_fpm: false

php8_enable_dev: no
php8_enable_dev: false

php8_ini_directives_default:
allow_url_fopen: no
allow_url_fopen: false
disable_functions: "exec, passthru, shell_exec, system, proc_open, popen, curl_exec, curl_multi_exec"
expose_php: no
session.cookie_httponly: yes
session.cookie_secure: yes
expose_php: false
session.cookie_httponly: true
session.cookie_secure: true
session.hash_bits_per_character: 4
session.hash_function: sha256
session.sid_bits_per_character: 4
session.sid_length: 64
session.use_strict_mode: yes
session.use_strict_mode: true

php8_ini_directives_global: {}
php8_ini_directives_cli: {}
php8_ini_directives_apache: {}
php8_ini_directives_cgi: {}
php8_ini_directives_fpm: {}

php8_extensions: []
php8_versioned_extensions: []

php8_fpm_pid: "/run/php/php{{ php8_version }}-fpm.pid"
php8_fpm_error_log: "/var/log/php{{ php8_version }}-fpm.log"
php8_fpm_log_level: warning
php8_fpm_syslog_facility: ~
php8_fpm_syslog_ident: ~
php8_fpm_syslog_facility:
php8_fpm_syslog_ident:
php8_fpm_emergency_restart_threshold: 0
php8_fpm_emergency_restart_interval: 0
php8_fpm_process_control_timeout: 0
php8_fpm_process_max: 0
php8_fpm_process_priority: ~
php8_fpm_daemonize: yes
php8_fpm_rlimit_files: ~
php8_fpm_rlimit_core: ~
php8_fpm_process_priority:
php8_fpm_daemonize: true
php8_fpm_rlimit_files:
php8_fpm_rlimit_core:
php8_fpm_events_mechanism: epoll
php8_fpm_systemd_interval: 10

php8_fpm_pool_enabled: yes
php8_fpm_pool_enabled: true
php8_fpm_pool_name: www
php8_fpm_pool_user: www-data
php8_fpm_pool_group: www-data
Expand All @@ -54,9 +52,9 @@ php8_fpm_pool_listen_backlog: 512
php8_fpm_pool_listen_owner: "{{ php8_fpm_pool_user }}"
php8_fpm_pool_listen_group: "{{ php8_fpm_pool_group }}"
php8_fpm_pool_listen_mode: "0660"
php8_fpm_pool_listen_acl_users: ~
php8_fpm_pool_listen_acl_groups: ~
php8_fpm_pool_listen_allowed_clients: ~
php8_fpm_pool_listen_acl_users:
php8_fpm_pool_listen_acl_groups:
php8_fpm_pool_listen_allowed_clients:
php8_fpm_pool_pm: dynamic
php8_fpm_pool_pm_max_children: 5
php8_fpm_pool_pm_start_servers: 2
Expand All @@ -67,17 +65,17 @@ php8_fpm_pool_pm_max_requests: 512
php8_fpm_pool_status_path: /status
php8_fpm_pool_ping_path: /ping
php8_fpm_pool_ping_response: pong
php8_fpm_pool_access_log: ~
php8_fpm_pool_access_format: ~
php8_fpm_pool_slowlog: ~
php8_fpm_pool_access_log:
php8_fpm_pool_access_format:
php8_fpm_pool_slowlog:
php8_fpm_pool_request_slowlog_timeout: 0
php8_fpm_pool_request_terminate_timeout: 0
php8_fpm_pool_rlimit_files: ~
php8_fpm_pool_rlimit_core: ~
php8_fpm_pool_chroot: ~
php8_fpm_pool_rlimit_files:
php8_fpm_pool_rlimit_core:
php8_fpm_pool_chroot:
php8_fpm_pool_chdir: /var/www
php8_fpm_pool_catch_workers_output: yes
php8_fpm_pool_clear_env: yes
php8_fpm_pool_catch_workers_output: true
php8_fpm_pool_clear_env: true
php8_fpm_pool_security_limit_extensions: .php
php8_fpm_pool_env: {}
php8_fpm_pool_php_admin_value: {}
Expand Down
Binary file added filter_plugins/__pycache__/prefix.cpython-313.pyc
Binary file not shown.
5 changes: 2 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
---

- name: Restart Apache
service:
ansible.builtin.service:
name: apache2
state: restarted
when: php8_enable_apache | bool

- name: Restart PHP FPM
service:
ansible.builtin.service:
name: "php{{ php8_version }}-fpm"
state: restarted
when: php8_enable_fpm | bool
9 changes: 5 additions & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

galaxy_info:
role_name: php8
namespace: f500
author: "Jasper N. Brouwer, Ramon de la Fuente"
description: Install PHP version 8.X from deb.sury.org
company: Future500
license: LGPL-3.0
min_ansible_version: "2.0"
platforms:
- name: Debian
versions:
- bullseye
- bookworm
- name: Debian
versions:
- bullseye
- bookworm
galaxy_tags:
- web
56 changes: 31 additions & 25 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,127 +1,133 @@
---

- name: Validate version value
fail:
ansible.builtin.fail:
msg: "The value of php8_version must >= 8.0 and < 9.0"
when: not (php8_version >= 8.0 and php8_version < 9.0)

- name: Install packages needed to use the deb.sury.org repository
apt:
name: ['apt-transport-https', 'ca-certificates']
ansible.builtin.apt:
name: ["apt-transport-https", "ca-certificates"]
state: present

- name: Add the deb.sury.org trusted key
ansible.builtin.get_url:
dest: /etc/apt/trusted.gpg.d/php.gpg
mode: 0644
force: yes
mode: "0644"
force: true
url: https://packages.sury.org/php/apt.gpg

- name: Add the deb.sury.org repository
apt_repository:
ansible.builtin.apt_repository:
repo: "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
update_cache: yes
update_cache: true

- name: Install PHP CLI
apt:
ansible.builtin.apt:
name: "php{{ php8_version }}-cli"

- name: Configure PHP for CLI
template:
ansible.builtin.template:
src: php.ini.j2
dest: "/etc/php/{{ php8_version }}/cli/conf.d/99-customization.ini"
mode: "0644"
vars:
php8_ini_directives: "{{ php8_ini_directives_default | combine(php8_ini_directives_global) | combine(php8_ini_directives_cli) }}"

- name: Install PHP module development files
apt:
ansible.builtin.apt:
name: "php{{ php8_version }}-dev"
when: php8_enable_dev | bool

- name: Install PHP Apache2 module
apt:
ansible.builtin.apt:
name: "libapache2-mod-php{{ php8_version }}"
when: php8_enable_apache | bool

- name: Configure PHP for Apache2
template:
ansible.builtin.template:
src: php.ini.j2
dest: "/etc/php/{{ php8_version }}/apache2/conf.d/99-customization.ini"
mode: "0644"
vars:
php8_ini_directives: "{{ php8_ini_directives_default | combine(php8_ini_directives_global) | combine(php8_ini_directives_apache) }}"
notify: Restart Apache
when: php8_enable_apache | bool

- name: Install PHP CGI binary
apt:
ansible.builtin.apt:
name: "php{{ php8_version }}-cgi"
when: php8_enable_cgi | bool

- name: Configure PHP for CGI
template:
ansible.builtin.template:
src: php.ini.j2
dest: "/etc/php/{{ php8_version }}/cgi/conf.d/99-customization.ini"
mode: "0644"
vars:
php8_ini_directives: "{{ php8_ini_directives_default | combine(php8_ini_directives_global) | combine(php8_ini_directives_cgi) }}"
when: php8_enable_cgi | bool

- name: Install PHP FPM binary
apt:
ansible.builtin.apt:
name: "php{{ php8_version }}-fpm"
when: php8_enable_fpm | bool

- name: Configure PHP for FPM
template:
ansible.builtin.template:
src: php.ini.j2
dest: "/etc/php/{{ php8_version }}/fpm/conf.d/99-customization.ini"
mode: "0644"
vars:
php8_ini_directives: "{{ php8_ini_directives_default | combine(php8_ini_directives_global) | combine(php8_ini_directives_fpm) }}"
notify: Restart PHP FPM
when: php8_enable_fpm | bool

- name: Configure FPM
template:
ansible.builtin.template:
src: php-fpm.conf.j2
dest: "/etc/php/{{ php8_version }}/fpm/php-fpm.conf"
mode: "0644"
notify: Restart PHP FPM
when: php8_enable_fpm | bool

- name: Ensure "chdir" in the standard pool exists
file:
ansible.builtin.file:
path: "{{ php8_fpm_pool_chdir }}"
state: directory
mode: "0755"
when: php8_enable_fpm | bool and php8_fpm_pool_enabled | bool

- name: Configure the standard pool for FPM
template:
ansible.builtin.template:
src: php-fpm-pool.conf.j2
dest: "/etc/php/{{ php8_version }}/fpm/pool.d/{{ php8_fpm_pool_name }}.conf"
mode: "0644"
notify: Restart PHP FPM
when: php8_enable_fpm | bool and php8_fpm_pool_enabled | bool

- name: Remove the standard pool for FPM
file:
ansible.builtin.file:
path: "/etc/php/{{ php8_version }}/fpm/pool.d/{{ php8_fpm_pool_name }}.conf"
state: absent
notify: Restart PHP FPM
when: php8_enable_fpm | bool and not php8_fpm_pool_enabled | bool

- name: Enable the FPM service
service:
ansible.builtin.service:
name: "php{{ php8_version }}-fpm"
enabled: yes
enabled: true
when: php8_enable_fpm | bool

- name: Install PHP extensions
apt:
ansible.builtin.apt:
name: "{{ php8_extensions | map('prefix', 'php-') | list }}"
state: present
notify:
- Restart Apache
- Restart PHP FPM

- name: Install versioned PHP extensions
apt:
ansible.builtin.apt:
name: "{{ php8_versioned_extensions | map('prefix', 'php' ~ php8_version ~ '-') | list }}"
notify:
- Restart Apache
Expand Down

0 comments on commit 18f7ba0

Please sign in to comment.