From a1dd9901ec5e0a456849a2808ee63d8a5f5180f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Thu, 3 Mar 2016 21:24:26 -0500 Subject: [PATCH] Add configurations to all possible conf directories --- tasks/configure.yml | 15 +++++++++------ tasks/install-from-source.yml | 4 ++-- tasks/main.yml | 17 +++++++++++------ tasks/setup-Debian.yml | 6 ++++-- vars/Debian.yml | 14 +++++++++++--- vars/RedHat.yml | 8 ++++++-- 6 files changed, 43 insertions(+), 21 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index 4e56ad2..a91e65e 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -4,38 +4,41 @@ path: "{{ item }}" state: directory follow: true - with_items: - - "{{ php_conf_path }}" - - "{{ php_extension_conf_path }}" + with_flattened: + - "{{ php_conf_paths }}" + - "{{ php_extension_conf_paths }}" - name: Place PHP configuration file in place. template: src: php.ini.j2 - dest: "{{ php_conf_path }}/php.ini" + dest: "{{ item }}/php.ini" owner: root group: root mode: 0644 + with_items: "{{ php_conf_paths }}" notify: restart webserver when: php_use_managed_ini - name: Place APC configuration file in place. template: src: apc.ini.j2 - dest: "{{ php_extension_conf_path }}/{{ php_apc_conf_filename }}" + dest: "{{ item }}/{{ php_apc_conf_filename }}" owner: root group: root force: yes mode: 0644 + with_items: "{{ php_extension_conf_paths }}" when: php_enable_apc notify: restart webserver - name: Place OpCache configuration file in place. template: src: opcache.ini.j2 - dest: "{{ php_extension_conf_path }}/{{ php_opcache_conf_filename }}" + dest: "{{ item }}/{{ php_opcache_conf_filename }}" owner: root group: root force: yes mode: 0644 + with_items: "{{ php_extension_conf_paths }}" when: php_opcache_enable notify: restart webserver diff --git a/tasks/install-from-source.yml b/tasks/install-from-source.yml index 718daae..2453866 100644 --- a/tasks/install-from-source.yml +++ b/tasks/install-from-source.yml @@ -132,14 +132,14 @@ - name: Ensure php-fpm config directory exists. file: - path: "{{ php_conf_path }}/fpm" + path: "{{ php_fpm_conf_path }}" state: directory when: "'--enable-fpm' in php_source_configure_command" - name: Ensure php-fpm config file is installed. template: src: php-fpm.conf.j2 - dest: "{{ php_conf_path }}/fpm/php-fpm.conf" + dest: "{{ php_fpm_conf_path }}/php-fpm.conf" mode: 0644 when: "'--enable-fpm' in php_source_configure_command" notify: restart php-fpm diff --git a/tasks/main.yml b/tasks/main.yml index 5c1d06a..3a0cc77 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,15 +13,15 @@ php_webserver_daemon: "{{ __php_webserver_daemon }}" when: php_webserver_daemon is not defined -- name: Define php_conf_path. +- name: Define php_conf_paths. set_fact: - php_conf_path: "{{ __php_conf_path }}" - when: php_conf_path is not defined + php_conf_paths: "{{ __php_conf_paths }}" + when: php_conf_paths is not defined -- name: Define php_extension_conf_path. +- name: Define php_extension_conf_paths. set_fact: - php_extension_conf_path: "{{ __php_extension_conf_path }}" - when: php_extension_conf_path is not defined + php_extension_conf_paths: "{{ __php_extension_conf_paths }}" + when: php_extension_conf_paths is not defined - name: Define php_apc_conf_filename. set_fact: @@ -33,6 +33,11 @@ php_opcache_conf_filename: "{{ __php_opcache_conf_filename }}" when: php_opcache_conf_filename is not defined +- name: Define php_fpm_conf_path. + set_fact: + php_fpm_conf_path: "{{ __php_fpm_conf_path }}" + when: php_fpm_conf_path is not defined + # Setup/install tasks. - include: setup-RedHat.yml when: (php_install_from_source == false) and (ansible_os_family == 'RedHat') diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index bfbbf27..a43684d 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -12,14 +12,16 @@ - name: Delete APC configuration file if this role will provide one. file: - path: "{{ php_extension_conf_path }}/{{ php_apc_conf_filename }}" + path: "{{ item }}/{{ php_apc_conf_filename }}" state: absent + with_items: "{{ php_extension_conf_paths }}" when: php_enable_apc and php_package_install.changed notify: restart webserver - name: Delete OpCache configuration file if this role will provide one. file: - path: "{{ php_extension_conf_path }}/{{ php_opcache_conf_filename }}" + path: "{{ item }}/{{ php_opcache_conf_filename }}" state: absent + with_items: "{{ php_extension_conf_paths }}" when: php_opcache_enable and php_package_install.changed notify: restart webserver diff --git a/vars/Debian.yml b/vars/Debian.yml index b78ae11..f6a78f9 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -14,10 +14,18 @@ __php_packages: __php_webserver_daemon: "apache2" # Vendor-specific configuration paths on Debian/Ubuntu make my brain asplode. -__php_conf_path: "{{ '/etc/php5/fpm' if php_enable_webserver and php_enable_php_fpm else '/etc/php5/apache2' if php_enable_webserver and php_webserver_daemon == 'apache2' else '/etc/php5/cli' }}" -__php_extension_conf_path: "{{ __php_conf_path }}/conf.d" +__php_conf_paths: + - /etc/php5/fpm + - /etc/php5/apache2 + - /etc/php5/cli + +__php_extension_conf_paths: + - /etc/php5/fpm/conf.d + - /etc/php5/apache2/conf.d + - /etc/php5/cli/conf.d __php_apc_conf_filename: 20-apcu.ini __php_opcache_conf_filename: 05-opcache.ini __php_fpm_daemon: php5-fpm -__php_fpm_pool_conf_path: "/etc/php5/fpm/pool.d/www.conf" +__php_fpm_conf_path: "/etc/php5/fpm" +__php_fpm_pool_conf_path: "{{ __php_fpm_conf_path }}/pool.d/www.conf" diff --git a/vars/RedHat.yml b/vars/RedHat.yml index c9cfdc4..64ef778 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -17,10 +17,14 @@ __php_packages: - php-xmlrpc __php_webserver_daemon: "httpd" -__php_conf_path: /etc -php_extension_conf_path: /etc/php.d +__php_conf_paths: + - /etc + +__php_extension_conf_paths: + - /etc/php.d __php_apc_conf_filename: 50-apc.ini __php_opcache_conf_filename: 10-opcache.ini __php_fpm_daemon: php-fpm +__php_fpm_conf_path: "/etc/fpm" __php_fpm_pool_conf_path: "/etc/php-fpm.d/www.conf"