From bf7accdadead63fb104e76d07e6d90264ea56f46 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Tue, 13 Sep 2016 15:50:50 +0300 Subject: [PATCH] roles/php-fpm: Only create pools for vhosts that need PHP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only vhosts running WordPress, etc need PHP. Make sure to set the appopriate variables for each vhost in the host's vars, ie: nginx_vhosts: - domain_name: example.com has_wordpress: True - domain_name: example.net needs_php: True You can set either of them, but not both—needing WordPress implies needing PHP. --- roles/php-fpm/tasks/Debian.yml | 3 ++- roles/php-fpm/tasks/Ubuntu.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/php-fpm/tasks/Debian.yml b/roles/php-fpm/tasks/Debian.yml index 371c975..fbc3bb8 100644 --- a/roles/php-fpm/tasks/Debian.yml +++ b/roles/php-fpm/tasks/Debian.yml @@ -9,10 +9,11 @@ - php5-curl tags: php-fpm, packages +# only copy php-fpm config for vhosts that need WordPress or PHP - name: Copy php5-fpm pool config template: src=pool.conf.j2 dest=/etc/php5/fpm/pool.d/{{ item.domain_name }}.conf owner=root group=root mode=0644 with_items: "{{ nginx_vhosts }}" - when: nginx_vhosts is defined + when: (item.has_wordpress is defined and item.has_wordpress == True) or (item.needs_php is defined and item.needs_php == True) notify: restart php5-fpm tags: php-fpm diff --git a/roles/php-fpm/tasks/Ubuntu.yml b/roles/php-fpm/tasks/Ubuntu.yml index c2ec940..8e2cd14 100644 --- a/roles/php-fpm/tasks/Ubuntu.yml +++ b/roles/php-fpm/tasks/Ubuntu.yml @@ -12,10 +12,11 @@ - php7.0-xml tags: php-fpm, packages +# only copy php-fpm config for vhosts that need WordPress or PHP - name: Copy php-fpm pool config template: src=php7.0-pool.conf.j2 dest=/etc/php/7.0/fpm/pool.d/{{ item.domain_name }}.conf owner=root group=root mode=0644 with_items: "{{ nginx_vhosts }}" - when: nginx_vhosts is defined + when: (item.has_wordpress is defined and item.has_wordpress == True) or (item.needs_php is defined and item.needs_php == True) notify: restart php7.0-fpm tags: php-fpm