roles/php-fpm: Only create pools for vhosts that need PHP

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.
This commit is contained in:
Alan Orth 2016-09-13 15:50:50 +03:00
parent 740e5195a0
commit bf7accdade
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 4 additions and 2 deletions

View File

@ -9,10 +9,11 @@
- php5-curl - php5-curl
tags: php-fpm, packages tags: php-fpm, packages
# only copy php-fpm config for vhosts that need WordPress or PHP
- name: Copy php5-fpm pool config - 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 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 }}" 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 notify: restart php5-fpm
tags: php-fpm tags: php-fpm

View File

@ -12,10 +12,11 @@
- php7.0-xml - php7.0-xml
tags: php-fpm, packages tags: php-fpm, packages
# only copy php-fpm config for vhosts that need WordPress or PHP
- name: Copy php-fpm pool config - 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 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 }}" 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 notify: restart php7.0-fpm
tags: php-fpm tags: php-fpm