From 1b68752c6b47c2d9210e6c681ed9179277a57c84 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 27 Apr 2020 15:43:14 +0200 Subject: [PATCH] Refactor the variables names so that we can install wp together with other PHP apps. --- defaults/main.yml | 13 ++++++++++--- templates/nginx_wordpress.conf.j2 | 4 ++++ vars/main.yml | 11 +++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 3781247..9993e26 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,4 +1,7 @@ --- +http_port: 80 +https_port: 443 + wordpress_dist_name: wordpress wordpress_major: 5 wordpress_minor: 3 @@ -41,8 +44,10 @@ wordpress_php_prereq: - 'php{{ php_version }}-mysqlnd' - 'php-apcu' - +php_global_settings: '{{ wordpress_php_global_settings }}' wordpress_local_mysql: True +wordpress_phpfpm_listen_on_socket: True +wordpress_php_listen: '{{ php_run_dir }}/wp.sock' wordpress_db_name: wp_db wordpress_db_user: wp_user @@ -58,5 +63,7 @@ wordpress_doc_root: /var/www/html/wordpress phpfpm_default_memory_limit: "128M" wordpress_upload_max_filesize: 32M nginx_client_max_body_size: '{{ wordpress_upload_max_filesize }}' -phpfpm_allow_url_fopen: 'on' -phpfpm_max_execution_time: '240' +phpfpm_allow_url_fopen: '{{ wordpress_phpfpm_allow_url_fopen }}' +phpfpm_max_execution_time: '{{ wordpress_phpfpm_max_execution_time }}' +phpfpm_pools: '{{ wordpress_phpfpm_pools }}' + diff --git a/templates/nginx_wordpress.conf.j2 b/templates/nginx_wordpress.conf.j2 index 1d4d6e8..eaf8d17 100644 --- a/templates/nginx_wordpress.conf.j2 +++ b/templates/nginx_wordpress.conf.j2 @@ -1,5 +1,9 @@ upstream php { +{% if wordpress_phpfpm_listen_on_socket %} + server unix:{{ item.listen }}; +{% else % server {{ item.listen }}; +{% endif %}} } server { diff --git a/vars/main.yml b/vars/main.yml index 68d7426..c2abfb8 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,7 +1,4 @@ --- -http_port: 80 -https_port: 443 - letsencrypt_acme_dest_dir: '{{ wordpress_servername }}' php_from_ppa: True @@ -13,7 +10,7 @@ phpfpm_cli_dir: '/etc/php{{ php_version }}/cli' mysql_db_data: - { name: '{{ wordpress_db_name }}', user: '{{ wordpress_db_user }}', pwd: '{{ wordpress_db_pwd }}', collation: '{{ mysql_default_collation }}', encoding: '{{ mysql_default_encoding }}', user_grant: 'ALL', allowed_hosts: [ '{{ ansible_fqdn }}/32', '127.0.0.1/8', 'localhost' ] } -php_global_settings: +wordpress_php_global_settings: - { option: 'always_populate_raw_post_data', value: '-1' } - { option: 'allow_url_fopen', value: '{{ phpfpm_allow_url_fopen }}' } - { option: 'max_execution_time', value: '{{ phpfpm_max_execution_time }}' } @@ -34,5 +31,7 @@ php_cli_global_settings: '{{ php_global_settings }}' phpfpm_default_pool_name: '{{ wordpress_system_user }}' phpfpm_default_user: '{{ wordpress_system_user }}' -phpfpm_pools: - - { pool_name: '{{ phpfpm_default_pool_name }}', app_context: '{{ phpfpm_default_context }}', user: '{{ phpfpm_default_user }}', group: '{{ phpfpm_default_group }}', listen: '{{ phpfpm_default_listen }}', allowed_clients: '{{ phpfpm_default_allowed_clients }}', pm: '{{ phpfpm_default_pm }}', pm_max_children: '{{ phpfpm_default_pm_max_children }}', pm_start_servers: '{{ phpfpm_default_pm_start_servers }}', pm_min_spare: '{{ phpfpm_default_pm_min_spare_servers }}', pm_max_spare: '{{ phpfpm_default_pm_max_spare_servers }}', pm_max_requests: '{{ phpfpm_default_pm_max_requests }}', pm_status_enabled: '{{ phpfpm_default_pm_status_enabled }}', pm_status_path: '{{ phpfpm_default_pm_status_path }}', ping_enabled: '{{ phpfpm_default_ping_enabled }}', ping_path: '{{ phpfpm_default_ping_path }}', ping_response: '{{ phpfpm_default_ping_response }}', display_errors: '{{ phpfpm_default_display_errors }}', log_errors: '{{ phpfpm_default_log_errors }}', memory_limit: '{{ phpfpm_default_memory_limit }}', slowlog_timeout: '{{ phpfpm_default_slowlog_timeout }}', rlimit_files: '{{ phpfpm_default_rlimit_files }}', php_extensions: '{{ phpfpm_default_extensions }}', define_custom_variables: '{{ phpfpm_default_define_custom_variables }}', admin_write: True, doc_root: '{{ wordpress_doc_root }}', virthost: '{{ wordpress_servername }}', virthost_aliases: "{{ wordpress_aliases | default('') }}" } \ No newline at end of file +wordpress_phpfpm_allow_url_fopen: 'on' +wordpress_phpfpm_max_execution_time: '240' +wordpress_phpfpm_pools: + - { pool_name: '{{ phpfpm_default_pool_name }}', app_context: '{{ phpfpm_default_context }}', user: '{{ phpfpm_default_user }}', group: '{{ phpfpm_default_group }}', listen: '{{ wordpress_php_listen }}', allowed_clients: '{{ phpfpm_default_allowed_clients }}', pm: '{{ phpfpm_default_pm }}', pm_max_children: '{{ phpfpm_default_pm_max_children }}', pm_start_servers: '{{ phpfpm_default_pm_start_servers }}', pm_min_spare: '{{ phpfpm_default_pm_min_spare_servers }}', pm_max_spare: '{{ phpfpm_default_pm_max_spare_servers }}', pm_max_requests: '{{ phpfpm_default_pm_max_requests }}', pm_status_enabled: '{{ phpfpm_default_pm_status_enabled }}', pm_status_path: '{{ phpfpm_default_pm_status_path }}', ping_enabled: '{{ phpfpm_default_ping_enabled }}', ping_path: '{{ phpfpm_default_ping_path }}', ping_response: '{{ phpfpm_default_ping_response }}', display_errors: '{{ phpfpm_default_display_errors }}', log_errors: '{{ phpfpm_default_log_errors }}', memory_limit: '{{ phpfpm_default_memory_limit }}', slowlog_timeout: '{{ phpfpm_default_slowlog_timeout }}', rlimit_files: '{{ phpfpm_default_rlimit_files }}', php_extensions: '{{ phpfpm_default_extensions }}', define_custom_variables: '{{ phpfpm_default_define_custom_variables }}', admin_write: True, doc_root: '{{ wordpress_doc_root }}', virthost: '{{ wordpress_servername }}', virthost_aliases: "{{ wordpress_aliases | default('') }}" }