From e78886400cfa7e4d88cb26e299b3f10f915ef4e6 Mon Sep 17 00:00:00 2001 From: Neil Prockter Date: Wed, 17 Dec 2014 23:19:17 +0000 Subject: [PATCH 1/6] add support for SUBDOMAIN_INSTALL and PATH_CURRENT_SITE options in wp-config.php --- README.markdown | 10 ++++++++-- manifests/app.pp | 4 ++++ manifests/init.pp | 12 +++++++++++- manifests/instance.pp | 10 ++++++++++ manifests/instance/app.pp | 8 ++++++-- templates/wp-config.php.erb | 4 ++-- 6 files changed, 41 insertions(+), 7 deletions(-) diff --git a/README.markdown b/README.markdown index 1f868cb..f33b6d3 100644 --- a/README.markdown +++ b/README.markdown @@ -63,7 +63,7 @@ This will set up one or more installations of Wordpress 3.8 on Debian and Redhat WordPress Plugin Directory. Full path, no trailing slash. Default: WordPress Default * `wp_additional_config`
- Specifies a template to include near the end of the wp-config.php file to add additional options. Default: '' + Specifies a template to include near the end of the wp-config.php file to add additional options. As PHP does not allow Defines to be redefined this can not be used to redefine values already defined. Default: '' * `wp_config_content`
Specifies the entire content for wp-config.php. This causes many of the other parameters to be ignored and allows an entirely custom config to be passed. It is recommended to use `wp_additional_config` instead of this parameter when possible. @@ -80,8 +80,14 @@ This will set up one or more installations of Wordpress 3.8 on Debian and Redhat * `wp_multisite`
Specifies whether to enable the multisite feature. Requires `wp_site_domain` to also be passed. Default: `false` +* `wp_subdomain_install`
+ Specifies the `SUBDOMAIN_INSTALL` value that will be used when configuring multisite. This states whether blogs created will be blogname.domain.com. Default: `false` + * `wp_site_domain`
- Specifies the `DOMAIN_CURRENT_SITE` value that will be used when configuring multisite. Typically this is the address of the main wordpress instance. Default: '' + Specifies the `DOMAIN_CURRENT_SITE` value that will be used when configuring multisite. Typically this is the address of the main wordpress instance. Default: '' + +* `wp_path_current_site`
+ Specifies the `PATH_CURRENT_SITE` value that will be used when configuring multisite. If all sites are to be under a url location that is not the toplevel / set this value /path/. wp-admin will then be at /path/wp-admin and additional blogs will be under /path/blogname. Default: '/' * `wp_debug`
Specifies the `WP_DEBUG` value that will control debugging. This must be true if you use the next two debug extensions. Default: 'false' diff --git a/manifests/app.pp b/manifests/app.pp index b9f42cc..708decb 100644 --- a/manifests/app.pp +++ b/manifests/app.pp @@ -16,7 +16,9 @@ $wp_proxy_host, $wp_proxy_port, $wp_multisite, + $wp_subdomain_install, $wp_site_domain, + $wp_path_current_site, $wp_debug, $wp_debug_log, $wp_debug_display, @@ -38,7 +40,9 @@ wp_proxy_host => $wp_proxy_host, wp_proxy_port => $wp_proxy_port, wp_multisite => $wp_multisite, + wp_subdomain_install => $wp_subdomain_install, wp_site_domain => $wp_site_domain, + wp_path_current_site => $wp_path_current_site, wp_debug => $wp_debug, wp_debug_log => $wp_debug_log, wp_debug_display => $wp_debug_display, diff --git a/manifests/init.pp b/manifests/init.pp index 4ba78c1..f97c6c8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -60,14 +60,20 @@ # Specifies a Hostname or IP of a proxy server for Wordpress to use to install updates, plugins, etc. Default: '' # # [*wp_proxy_port*] -# Specifies the port to use with the proxy host. Default: '' +# Specifies the port to use with the proxy host. Default: '' # # [*wp_multisite*] # Specifies whether to enable the multisite feature. Requires `wp_site_domain` to also be passed. Default: `false` # +# [*wp_subdomain_install*] +# Specifies the `SUBDOMAIN_INSTALL` value that will be used when configuring multisite. This states whether blogs created will be blogname.domain +# # [*wp_site_domain*] # Specifies the `DOMAIN_CURRENT_SITE` value that will be used when configuring multisite. Typically this is the address of the main wordpress instance. Default: '' # +# [*wp_path_current_site*] +# Specifies the `PATH_CURRENT_SITE` value that will be used when configuring multisite. If all sites are to be under a url location that is not t +# # [*wp_debug*] # Specifies the `WP_DEBUG` value that will control debugging. This must be true if you use the next two debug extensions. Default: 'false' # @@ -101,7 +107,9 @@ $wp_proxy_host = '', $wp_proxy_port = '', $wp_multisite = false, + $wp_subdomain_install = false, $wp_site_domain = '', + $wp_path_current_site = '/', $wp_debug = false, $wp_debug_log = false, $wp_debug_display = false, @@ -126,7 +134,9 @@ wp_proxy_host => $wp_proxy_host, wp_proxy_port => $wp_proxy_port, wp_multisite => $wp_multisite, + wp_subdomain_install => $wp_subdomain_install, wp_site_domain => $wp_site_domain, + wp_path_current_site => $wp_path_current_site, wp_debug => $wp_debug, wp_debug_log => $wp_debug_log, wp_debug_display => $wp_debug_display, diff --git a/manifests/instance.pp b/manifests/instance.pp index bd4c0a8..6c5c658 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -63,9 +63,15 @@ # [*wp_multisite*] # Specifies whether to enable the multisite feature. Requires `wp_site_domain` to also be passed. Default: `false` # +# [*wp_subdomain_install*] +# Specifies the `SUBDOMAIN_INSTALL` value that will be used when configuring multisite. This states whether blogs created will be blogname.domain +# # [*wp_site_domain*] # Specifies the `DOMAIN_CURRENT_SITE` value that will be used when configuring multisite. Typically this is the address of the main wordpress instance. Default: '' # +# [*wp_path_current_site*] +# Specifies the `PATH_CURRENT_SITE` value that will be used when configuring multisite. If all sites are to be under a url location that is not t +# # === Requires # # === Examples @@ -90,7 +96,9 @@ $wp_proxy_host = '', $wp_proxy_port = '', $wp_multisite = false, + $wp_subdomain_install = false, $wp_site_domain = '', + $wp_path_current_site = '/', $wp_debug = false, $wp_debug_log = false, $wp_debug_display = false, @@ -113,7 +121,9 @@ wp_proxy_host => $wp_proxy_host, wp_proxy_port => $wp_proxy_port, wp_multisite => $wp_multisite, + wp_subdomain_install => $wp_subdomain_install, wp_site_domain => $wp_site_domain, + wp_path_current_site => $wp_path_current_site, wp_debug => $wp_debug, wp_debug_log => $wp_debug_log, wp_debug_display => $wp_debug_display, diff --git a/manifests/instance/app.pp b/manifests/instance/app.pp index 0f4379a..f59e4a4 100644 --- a/manifests/instance/app.pp +++ b/manifests/instance/app.pp @@ -16,13 +16,15 @@ $wp_proxy_host, $wp_proxy_port, $wp_multisite, + $wp_subdomain_install, $wp_site_domain, + $wp_path_current_site, $wp_debug, $wp_debug_log, $wp_debug_display, ) { - validate_string($install_dir,$install_url,$version,$db_name,$db_host,$db_user,$db_password,$wp_owner,$wp_group, $wp_lang, $wp_plugin_dir,$wp_additional_config,$wp_table_prefix,$wp_proxy_host,$wp_proxy_port,$wp_site_domain) - validate_bool($wp_multisite, $wp_debug, $wp_debug_log, $wp_debug_display) + validate_string($install_dir,$install_url,$version,$db_name,$db_host,$db_user,$db_password,$wp_owner,$wp_group, $wp_lang, $wp_plugin_dir,$wp_additional_config,$wp_table_prefix,$wp_proxy_host,$wp_proxy_port,$wp_site_domain,$wp_path_current_site) + validate_bool($wp_multisite, $wp_subdomain_install, $wp_debug, $wp_debug_log, $wp_debug_display) validate_absolute_path($install_dir) if $wp_config_content and ($wp_lang or $wp_debug or $wp_debug_log or $wp_debug_display or $wp_proxy_host or $wp_proxy_port or $wp_multisite or $wp_site_domain) { @@ -130,7 +132,9 @@ # - $wp_proxy_host # - $wp_proxy_port # - $wp_multisite + # - $wp_subdomain_install # - $wp_site_domain + # - $wp_path_current_site # - $wp_additional_config # - $wp_debug # - $wp_debug_log diff --git a/templates/wp-config.php.erb b/templates/wp-config.php.erb index 25d6a53..95b7411 100644 --- a/templates/wp-config.php.erb +++ b/templates/wp-config.php.erb @@ -89,9 +89,9 @@ define('WP_PROXY_PORT', '<%= @wp_proxy_port %>'); /* Multisite */ define('WP_ALLOW_MULTISITE', true); define('MULTISITE', true); -define('SUBDOMAIN_INSTALL', true); +define('SUBDOMAIN_INSTALL', <%= @wp_subdomain_install %>); define('DOMAIN_CURRENT_SITE', '<%= @wp_site_domain %>'); -define('PATH_CURRENT_SITE', '/'); +define('PATH_CURRENT_SITE', '<%= @wp_path_current_site %>'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1); <% end %> From d9870d62b5e54409b752fb40ec76016dfcd58a6c Mon Sep 17 00:00:00 2001 From: Neil Prockter Date: Wed, 20 May 2015 16:02:41 +0100 Subject: [PATCH 2/6] when we are upgrading index.php will already exist so using it as a create is pony --- manifests/instance/app.pp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/manifests/instance/app.pp b/manifests/instance/app.pp index f59e4a4..f9af4d4 100644 --- a/manifests/instance/app.pp +++ b/manifests/instance/app.pp @@ -80,9 +80,8 @@ user => $wp_owner, group => $wp_group, } - -> exec { "Extract wordpress ${install_dir}": + ~> exec { "Extract wordpress ${install_dir}": command => "tar zxvf ./${install_file_name} --strip-components=1", - creates => "${install_dir}/index.php", user => $wp_owner, group => $wp_group, } From f7daf3eba9f861cf7f22dfe3cc94b37422202f0a Mon Sep 17 00:00:00 2001 From: Neil Prockter Date: Wed, 20 May 2015 16:05:02 +0100 Subject: [PATCH 3/6] This was poorly thought through removing the tar file would now re download extract and chmod the exec extract needs better logic Revert "when we are upgrading index.php will already exist so using it as a create is pony" This reverts commit d9870d62b5e54409b752fb40ec76016dfcd58a6c. --- manifests/instance/app.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/instance/app.pp b/manifests/instance/app.pp index f9af4d4..f59e4a4 100644 --- a/manifests/instance/app.pp +++ b/manifests/instance/app.pp @@ -80,8 +80,9 @@ user => $wp_owner, group => $wp_group, } - ~> exec { "Extract wordpress ${install_dir}": + -> exec { "Extract wordpress ${install_dir}": command => "tar zxvf ./${install_file_name} --strip-components=1", + creates => "${install_dir}/index.php", user => $wp_owner, group => $wp_group, } From 463b005a420d9d2c889a5467388b4b7c4709ed36 Mon Sep 17 00:00:00 2001 From: Neil Prockter Date: Wed, 20 May 2015 16:13:58 +0100 Subject: [PATCH 4/6] hackery perhaps --- manifests/instance/app.pp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/manifests/instance/app.pp b/manifests/instance/app.pp index f59e4a4..33a1c50 100644 --- a/manifests/instance/app.pp +++ b/manifests/instance/app.pp @@ -80,6 +80,12 @@ user => $wp_owner, group => $wp_group, } + ~> exec { "trash index.php": + command => "rm ${install_dir}/index.php", + refreshonly => true, + user => $wp_owner, + group => $wp_group, + } -> exec { "Extract wordpress ${install_dir}": command => "tar zxvf ./${install_file_name} --strip-components=1", creates => "${install_dir}/index.php", From da2182ebb43eb138761f715a759a88257826e728 Mon Sep 17 00:00:00 2001 From: Neil Prockter Date: Wed, 20 May 2015 16:17:05 +0100 Subject: [PATCH 5/6] Revert "hackery perhaps" This reverts commit 463b005a420d9d2c889a5467388b4b7c4709ed36. this was just as bad still removing the tar downloads it, then removes index.php which then sets the exec to untar it off we need knowledge of the running version of php maybe use wp cli program or run a curl xmlrpc call which is least yuck --- manifests/instance/app.pp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/manifests/instance/app.pp b/manifests/instance/app.pp index 33a1c50..f59e4a4 100644 --- a/manifests/instance/app.pp +++ b/manifests/instance/app.pp @@ -80,12 +80,6 @@ user => $wp_owner, group => $wp_group, } - ~> exec { "trash index.php": - command => "rm ${install_dir}/index.php", - refreshonly => true, - user => $wp_owner, - group => $wp_group, - } -> exec { "Extract wordpress ${install_dir}": command => "tar zxvf ./${install_file_name} --strip-components=1", creates => "${install_dir}/index.php", From 847c2a7f19b17e6214bebcaceffb6e95115a6d66 Mon Sep 17 00:00:00 2001 From: Chris Fryer Date: Tue, 16 Jan 2018 15:00:30 +0000 Subject: [PATCH 6/6] Chamge default mode of wordpress files to 0664 This will allow members of the group $wp_group to write to the wordpress directory, enabling them to run wp-cli etc without sudo. There shouldn't be any risk here; by default, $wp_group is '0', i.e. root --- manifests/instance/app.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/instance/app.pp b/manifests/instance/app.pp index f59e4a4..6601e06 100644 --- a/manifests/instance/app.pp +++ b/manifests/instance/app.pp @@ -47,7 +47,7 @@ File { owner => $wp_owner, group => $wp_group, - mode => '0644', + mode => '0664', } Exec { path => ['/bin','/sbin','/usr/bin','/usr/sbin'],