Alan Orth
81c1231a28
First, we cannot do a global check for has_wordpress or needs_php, as those are defined per nginx vhost. Second, I realized that this was only working in the past because vhosts that had WordPress or needed PHP were listed first in the nginx_vhosts dict. This changes the logic to first check if any vhosts have WordPress or need PHP, then sets a fact that we can use to decide whether to run php-fpm tasks or not.
36 lines
1.0 KiB
YAML
36 lines
1.0 KiB
YAML
---
|
|
|
|
- block:
|
|
- name: Set php-fpm packages
|
|
set_fact:
|
|
php_fpm_packages:
|
|
- php-fpm
|
|
# for WordPress
|
|
- php-mysql
|
|
- php-gd
|
|
- php-curl
|
|
|
|
- name: Install php-fpm and deps
|
|
apt: name={{ php_fpm_packages }} state=present update_cache=yes
|
|
|
|
# only copy php-fpm config for vhosts that need WordPress or PHP
|
|
- name: Copy php-fpm pool config
|
|
template: src=php7.4-pool.conf.j2 dest=/etc/php/7.4/fpm/pool.d/{{ item.domain_name }}.conf owner=root group=root mode=0644
|
|
loop: "{{ nginx_vhosts }}"
|
|
when: (item.has_wordpress is defined and item.has_wordpress) or (item.needs_php is defined and item.needs_php)
|
|
notify: reload php7.4-fpm
|
|
|
|
- name: Remove default www pool
|
|
file: path=/etc/php/7.4/fpm/pool.d/www.conf state=absent
|
|
notify: reload php7.4-fpm
|
|
|
|
# re-configure php.ini
|
|
- name: Update php.ini
|
|
template: src=php7.4-php.ini.j2 dest=/etc/php/7.4/fpm/php.ini owner=root group=root mode=0644
|
|
notify: reload php7.4-fpm
|
|
|
|
tags: php-fpm
|
|
when: install_php
|
|
|
|
# vim: set ts=2 sw=2:
|