|
25 | 25 | loop_control: |
26 | 26 | label: "{{ item.key }}" |
27 | 27 |
|
| 28 | +- name: Ensure configured WordPress runtime group exists |
| 29 | + getent: |
| 30 | + database: group |
| 31 | + key: "{{ wordpress_runtime_group }}" |
| 32 | + when: wordpress_runtime_hardened |
| 33 | + |
| 34 | +- name: Ensure configured WordPress runtime user exists |
| 35 | + getent: |
| 36 | + database: passwd |
| 37 | + key: "{{ wordpress_runtime_user }}" |
| 38 | + when: wordpress_runtime_hardened |
| 39 | + |
| 40 | +- name: Ensure hardened writable paths exist and are owned by runtime user |
| 41 | + include_tasks: runtime-writable-paths.yml |
| 42 | + loop: "{{ wordpress_sites | dict2items }}" |
| 43 | + loop_control: |
| 44 | + label: "{{ item.key }}" |
| 45 | + when: wordpress_runtime_hardened |
| 46 | + |
28 | 47 | - name: Create WordPress php-fpm configuration file |
29 | 48 | template: |
30 | 49 | src: php-fpm-pool-wordpress.conf.j2 |
|
49 | 68 | cron: |
50 | 69 | name: "{{ item.key }} WordPress cron" |
51 | 70 | minute: "{{ item.value.cron_interval | default('*/15') }}" |
52 | | - user: "{{ web_user }}" |
| 71 | + user: "{{ (wordpress_runtime_hardened and wordpress_runtime_cron_as_runtime_user) | ternary(wordpress_runtime_user, web_user) }}" |
53 | 72 | job: "cd {{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }} && wp cron event run --due-now > /dev/null 2>&1" |
54 | 73 | cron_file: "wordpress-{{ item.key | replace('.', '_') }}" |
55 | 74 | state: "{{ (cron_enabled and not item.value.multisite.enabled) | ternary('present', 'absent') }}" |
|
61 | 80 | cron: |
62 | 81 | name: "{{ item.key }} WordPress network cron" |
63 | 82 | minute: "{{ item.value.cron_interval_multisite | default('*/30') }}" |
64 | | - user: "{{ web_user }}" |
| 83 | + user: "{{ (wordpress_runtime_hardened and wordpress_runtime_cron_as_runtime_user) | ternary(wordpress_runtime_user, web_user) }}" |
65 | 84 | job: "cd {{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }} && (wp site list --field=url | xargs -n1 -I \\% wp --url=\\% cron event run --due-now) > /dev/null 2>&1" |
66 | 85 | cron_file: "wordpress-multisite-{{ item.key | replace('.', '_') }}" |
67 | 86 | state: "{{ (cron_enabled and item.value.multisite.enabled) | ternary('present', 'absent') }}" |
|
0 commit comments