Skip to content

Commit 18f7ba0

Browse files
committed
Fix issues
1 parent 265263c commit 18f7ba0

File tree

5 files changed

+65
-61
lines changed

5 files changed

+65
-61
lines changed

defaults/main.yml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,48 @@
22

33
php8_version: 8.0
44

5-
php8_enable_apache: no
6-
php8_enable_cgi: no
7-
php8_enable_fpm: no
5+
php8_enable_apache: false
6+
php8_enable_cgi: false
7+
php8_enable_fpm: false
88

9-
php8_enable_dev: no
9+
php8_enable_dev: false
1010

1111
php8_ini_directives_default:
12-
allow_url_fopen: no
12+
allow_url_fopen: false
1313
disable_functions: "exec, passthru, shell_exec, system, proc_open, popen, curl_exec, curl_multi_exec"
14-
expose_php: no
15-
session.cookie_httponly: yes
16-
session.cookie_secure: yes
14+
expose_php: false
15+
session.cookie_httponly: true
16+
session.cookie_secure: true
1717
session.hash_bits_per_character: 4
1818
session.hash_function: sha256
1919
session.sid_bits_per_character: 4
2020
session.sid_length: 64
21-
session.use_strict_mode: yes
21+
session.use_strict_mode: true
2222

2323
php8_ini_directives_global: {}
2424
php8_ini_directives_cli: {}
2525
php8_ini_directives_apache: {}
2626
php8_ini_directives_cgi: {}
2727
php8_ini_directives_fpm: {}
28-
2928
php8_extensions: []
3029
php8_versioned_extensions: []
31-
3230
php8_fpm_pid: "/run/php/php{{ php8_version }}-fpm.pid"
3331
php8_fpm_error_log: "/var/log/php{{ php8_version }}-fpm.log"
3432
php8_fpm_log_level: warning
35-
php8_fpm_syslog_facility: ~
36-
php8_fpm_syslog_ident: ~
33+
php8_fpm_syslog_facility:
34+
php8_fpm_syslog_ident:
3735
php8_fpm_emergency_restart_threshold: 0
3836
php8_fpm_emergency_restart_interval: 0
3937
php8_fpm_process_control_timeout: 0
4038
php8_fpm_process_max: 0
41-
php8_fpm_process_priority: ~
42-
php8_fpm_daemonize: yes
43-
php8_fpm_rlimit_files: ~
44-
php8_fpm_rlimit_core: ~
39+
php8_fpm_process_priority:
40+
php8_fpm_daemonize: true
41+
php8_fpm_rlimit_files:
42+
php8_fpm_rlimit_core:
4543
php8_fpm_events_mechanism: epoll
4644
php8_fpm_systemd_interval: 10
4745

48-
php8_fpm_pool_enabled: yes
46+
php8_fpm_pool_enabled: true
4947
php8_fpm_pool_name: www
5048
php8_fpm_pool_user: www-data
5149
php8_fpm_pool_group: www-data
@@ -54,9 +52,9 @@ php8_fpm_pool_listen_backlog: 512
5452
php8_fpm_pool_listen_owner: "{{ php8_fpm_pool_user }}"
5553
php8_fpm_pool_listen_group: "{{ php8_fpm_pool_group }}"
5654
php8_fpm_pool_listen_mode: "0660"
57-
php8_fpm_pool_listen_acl_users: ~
58-
php8_fpm_pool_listen_acl_groups: ~
59-
php8_fpm_pool_listen_allowed_clients: ~
55+
php8_fpm_pool_listen_acl_users:
56+
php8_fpm_pool_listen_acl_groups:
57+
php8_fpm_pool_listen_allowed_clients:
6058
php8_fpm_pool_pm: dynamic
6159
php8_fpm_pool_pm_max_children: 5
6260
php8_fpm_pool_pm_start_servers: 2
@@ -67,17 +65,17 @@ php8_fpm_pool_pm_max_requests: 512
6765
php8_fpm_pool_status_path: /status
6866
php8_fpm_pool_ping_path: /ping
6967
php8_fpm_pool_ping_response: pong
70-
php8_fpm_pool_access_log: ~
71-
php8_fpm_pool_access_format: ~
72-
php8_fpm_pool_slowlog: ~
68+
php8_fpm_pool_access_log:
69+
php8_fpm_pool_access_format:
70+
php8_fpm_pool_slowlog:
7371
php8_fpm_pool_request_slowlog_timeout: 0
7472
php8_fpm_pool_request_terminate_timeout: 0
75-
php8_fpm_pool_rlimit_files: ~
76-
php8_fpm_pool_rlimit_core: ~
77-
php8_fpm_pool_chroot: ~
73+
php8_fpm_pool_rlimit_files:
74+
php8_fpm_pool_rlimit_core:
75+
php8_fpm_pool_chroot:
7876
php8_fpm_pool_chdir: /var/www
79-
php8_fpm_pool_catch_workers_output: yes
80-
php8_fpm_pool_clear_env: yes
77+
php8_fpm_pool_catch_workers_output: true
78+
php8_fpm_pool_clear_env: true
8179
php8_fpm_pool_security_limit_extensions: .php
8280
php8_fpm_pool_env: {}
8381
php8_fpm_pool_php_admin_value: {}
Binary file not shown.

handlers/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
2-
32
- name: Restart Apache
4-
service:
3+
ansible.builtin.service:
54
name: apache2
65
state: restarted
76
when: php8_enable_apache | bool
87

98
- name: Restart PHP FPM
10-
service:
9+
ansible.builtin.service:
1110
name: "php{{ php8_version }}-fpm"
1211
state: restarted
1312
when: php8_enable_fpm | bool

meta/main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
galaxy_info:
44
role_name: php8
5+
namespace: f500
56
author: "Jasper N. Brouwer, Ramon de la Fuente"
67
description: Install PHP version 8.X from deb.sury.org
78
company: Future500
89
license: LGPL-3.0
910
min_ansible_version: "2.0"
1011
platforms:
11-
- name: Debian
12-
versions:
13-
- bullseye
14-
- bookworm
12+
- name: Debian
13+
versions:
14+
- bullseye
15+
- bookworm
1516
galaxy_tags:
1617
- web

tasks/main.yml

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,133 @@
11
---
2-
32
- name: Validate version value
4-
fail:
3+
ansible.builtin.fail:
54
msg: "The value of php8_version must >= 8.0 and < 9.0"
65
when: not (php8_version >= 8.0 and php8_version < 9.0)
76

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

1312
- name: Add the deb.sury.org trusted key
1413
ansible.builtin.get_url:
1514
dest: /etc/apt/trusted.gpg.d/php.gpg
16-
mode: 0644
17-
force: yes
15+
mode: "0644"
16+
force: true
1817
url: https://packages.sury.org/php/apt.gpg
1918

2019
- name: Add the deb.sury.org repository
21-
apt_repository:
20+
ansible.builtin.apt_repository:
2221
repo: "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
23-
update_cache: yes
22+
update_cache: true
2423

2524
- name: Install PHP CLI
26-
apt:
25+
ansible.builtin.apt:
2726
name: "php{{ php8_version }}-cli"
2827

2928
- name: Configure PHP for CLI
30-
template:
29+
ansible.builtin.template:
3130
src: php.ini.j2
3231
dest: "/etc/php/{{ php8_version }}/cli/conf.d/99-customization.ini"
32+
mode: "0644"
3333
vars:
3434
php8_ini_directives: "{{ php8_ini_directives_default | combine(php8_ini_directives_global) | combine(php8_ini_directives_cli) }}"
3535

3636
- name: Install PHP module development files
37-
apt:
37+
ansible.builtin.apt:
3838
name: "php{{ php8_version }}-dev"
3939
when: php8_enable_dev | bool
4040

4141
- name: Install PHP Apache2 module
42-
apt:
42+
ansible.builtin.apt:
4343
name: "libapache2-mod-php{{ php8_version }}"
4444
when: php8_enable_apache | bool
4545

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

5556
- name: Install PHP CGI binary
56-
apt:
57+
ansible.builtin.apt:
5758
name: "php{{ php8_version }}-cgi"
5859
when: php8_enable_cgi | bool
5960

6061
- name: Configure PHP for CGI
61-
template:
62+
ansible.builtin.template:
6263
src: php.ini.j2
6364
dest: "/etc/php/{{ php8_version }}/cgi/conf.d/99-customization.ini"
65+
mode: "0644"
6466
vars:
6567
php8_ini_directives: "{{ php8_ini_directives_default | combine(php8_ini_directives_global) | combine(php8_ini_directives_cgi) }}"
6668
when: php8_enable_cgi | bool
6769

6870
- name: Install PHP FPM binary
69-
apt:
71+
ansible.builtin.apt:
7072
name: "php{{ php8_version }}-fpm"
7173
when: php8_enable_fpm | bool
7274

7375
- name: Configure PHP for FPM
74-
template:
76+
ansible.builtin.template:
7577
src: php.ini.j2
7678
dest: "/etc/php/{{ php8_version }}/fpm/conf.d/99-customization.ini"
79+
mode: "0644"
7780
vars:
7881
php8_ini_directives: "{{ php8_ini_directives_default | combine(php8_ini_directives_global) | combine(php8_ini_directives_fpm) }}"
7982
notify: Restart PHP FPM
8083
when: php8_enable_fpm | bool
8184

8285
- name: Configure FPM
83-
template:
86+
ansible.builtin.template:
8487
src: php-fpm.conf.j2
8588
dest: "/etc/php/{{ php8_version }}/fpm/php-fpm.conf"
89+
mode: "0644"
8690
notify: Restart PHP FPM
8791
when: php8_enable_fpm | bool
8892

8993
- name: Ensure "chdir" in the standard pool exists
90-
file:
94+
ansible.builtin.file:
9195
path: "{{ php8_fpm_pool_chdir }}"
9296
state: directory
97+
mode: "0755"
9398
when: php8_enable_fpm | bool and php8_fpm_pool_enabled | bool
9499

95100
- name: Configure the standard pool for FPM
96-
template:
101+
ansible.builtin.template:
97102
src: php-fpm-pool.conf.j2
98103
dest: "/etc/php/{{ php8_version }}/fpm/pool.d/{{ php8_fpm_pool_name }}.conf"
104+
mode: "0644"
99105
notify: Restart PHP FPM
100106
when: php8_enable_fpm | bool and php8_fpm_pool_enabled | bool
101107

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

109115
- name: Enable the FPM service
110-
service:
116+
ansible.builtin.service:
111117
name: "php{{ php8_version }}-fpm"
112-
enabled: yes
118+
enabled: true
113119
when: php8_enable_fpm | bool
114120

115121
- name: Install PHP extensions
116-
apt:
122+
ansible.builtin.apt:
117123
name: "{{ php8_extensions | map('prefix', 'php-') | list }}"
118124
state: present
119125
notify:
120126
- Restart Apache
121127
- Restart PHP FPM
122128

123129
- name: Install versioned PHP extensions
124-
apt:
130+
ansible.builtin.apt:
125131
name: "{{ php8_versioned_extensions | map('prefix', 'php' ~ php8_version ~ '-') | list }}"
126132
notify:
127133
- Restart Apache

0 commit comments

Comments
 (0)