Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature add parameter wp additional inline config #53

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ This will set up one or more installations of Wordpress 3.8 on Debian and Redhat
* `wp_additional_config`<br />
Specifies a template to include near the end of the wp-config.php file to add additional options. Default: ''

* `wp_additional_inline_config`<br />
Specifies a hash of additional configuration options to include near the end of the wp-config.php file. Default: '{}'

* `wp_config_content`<br />
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.

Expand Down Expand Up @@ -210,3 +213,11 @@ class { 'wordpress':
wp_additional_config => 'foo/wp-config-extra.php.erb',
}
```

Add inline configuration to wp-config.php:

```puppet
class { 'wordpress':
wp_additional_inline_config => {'FOO' => 'bar', 'BAZ' => 1234, 'WP_CACHE' => true},
}
```
42 changes: 22 additions & 20 deletions manifests/app.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$wp_config_content,
$wp_plugin_dir,
$wp_additional_config,
$wp_additional_inline_config,
$wp_table_prefix,
$wp_proxy_host,
$wp_proxy_port,
Expand All @@ -22,25 +23,26 @@
$wp_debug_display,
) {
wordpress::instance::app { $install_dir:
install_dir => $install_dir,
install_url => $install_url,
version => $version,
db_name => $db_name,
db_host => $db_host,
db_user => $db_user,
db_password => $db_password,
wp_owner => $wp_owner,
wp_group => $wp_group,
wp_lang => $wp_lang,
wp_plugin_dir => $wp_plugin_dir,
wp_additional_config => $wp_additional_config,
wp_table_prefix => $wp_table_prefix,
wp_proxy_host => $wp_proxy_host,
wp_proxy_port => $wp_proxy_port,
wp_multisite => $wp_multisite,
wp_site_domain => $wp_site_domain,
wp_debug => $wp_debug,
wp_debug_log => $wp_debug_log,
wp_debug_display => $wp_debug_display,
install_dir => $install_dir,
install_url => $install_url,
version => $version,
db_name => $db_name,
db_host => $db_host,
db_user => $db_user,
db_password => $db_password,
wp_owner => $wp_owner,
wp_group => $wp_group,
wp_lang => $wp_lang,
wp_plugin_dir => $wp_plugin_dir,
wp_additional_config => $wp_additional_config,
wp_additional_inline_config => $wp_additional_inline_config,
wp_table_prefix => $wp_table_prefix,
wp_proxy_host => $wp_proxy_host,
wp_proxy_port => $wp_proxy_port,
wp_multisite => $wp_multisite,
wp_site_domain => $wp_site_domain,
wp_debug => $wp_debug,
wp_debug_log => $wp_debug_log,
wp_debug_display => $wp_debug_display,
}
}
98 changes: 51 additions & 47 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@
# [*wp_lang*]
# WordPress Localized Language. Default: ''
#
#
# [*wp_plugin_dir*]
# 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: ''
#
# [*wp_additional_inline_config*]
# Specifies a hash of additional configuration options to include near the end of the wp-config.php file. Default: '{}'
#
# [*wp_table_prefix*]
# Specifies the database table prefix. Default: wp_
#
Expand Down Expand Up @@ -82,53 +84,55 @@
# === Examples
#
class wordpress (
$install_dir = '/opt/wordpress',
$install_url = 'http://wordpress.org',
$version = '3.8',
$create_db = true,
$create_db_user = true,
$db_name = 'wordpress',
$db_host = 'localhost',
$db_user = 'wordpress',
$db_password = 'password',
$wp_owner = 'root',
$wp_group = '0',
$wp_lang = '',
$wp_config_content = undef,
$wp_plugin_dir = 'DEFAULT',
$wp_additional_config = 'DEFAULT',
$wp_table_prefix = 'wp_',
$wp_proxy_host = '',
$wp_proxy_port = '',
$wp_multisite = false,
$wp_site_domain = '',
$wp_debug = false,
$wp_debug_log = false,
$wp_debug_display = false,
$install_dir = '/opt/wordpress',
$install_url = 'http://wordpress.org',
$version = '3.8',
$create_db = true,
$create_db_user = true,
$db_name = 'wordpress',
$db_host = 'localhost',
$db_user = 'wordpress',
$db_password = 'password',
$wp_owner = 'root',
$wp_group = '0',
$wp_lang = '',
$wp_config_content = undef,
$wp_plugin_dir = 'DEFAULT',
$wp_additional_config = 'DEFAULT',
$wp_additional_inline_config = {},
$wp_table_prefix = 'wp_',
$wp_proxy_host = '',
$wp_proxy_port = '',
$wp_multisite = false,
$wp_site_domain = '',
$wp_debug = false,
$wp_debug_log = false,
$wp_debug_display = false,
) {
wordpress::instance { $install_dir:
install_dir => $install_dir,
install_url => $install_url,
version => $version,
create_db => $create_db,
create_db_user => $create_db_user,
db_name => $db_name,
db_host => $db_host,
db_user => $db_user,
db_password => $db_password,
wp_owner => $wp_owner,
wp_group => $wp_group,
wp_lang => $wp_lang,
wp_config_content => $wp_config_content,
wp_plugin_dir => $wp_plugin_dir,
wp_additional_config => $wp_additional_config,
wp_table_prefix => $wp_table_prefix,
wp_proxy_host => $wp_proxy_host,
wp_proxy_port => $wp_proxy_port,
wp_multisite => $wp_multisite,
wp_site_domain => $wp_site_domain,
wp_debug => $wp_debug,
wp_debug_log => $wp_debug_log,
wp_debug_display => $wp_debug_display,
install_dir => $install_dir,
install_url => $install_url,
version => $version,
create_db => $create_db,
create_db_user => $create_db_user,
db_name => $db_name,
db_host => $db_host,
db_user => $db_user,
db_password => $db_password,
wp_owner => $wp_owner,
wp_group => $wp_group,
wp_lang => $wp_lang,
wp_config_content => $wp_config_content,
wp_plugin_dir => $wp_plugin_dir,
wp_additional_config => $wp_additional_config,
wp_additional_inline_config => $wp_additional_inline_config,
wp_table_prefix => $wp_table_prefix,
wp_proxy_host => $wp_proxy_host,
wp_proxy_port => $wp_proxy_port,
wp_multisite => $wp_multisite,
wp_site_domain => $wp_site_domain,
wp_debug => $wp_debug,
wp_debug_log => $wp_debug_log,
wp_debug_display => $wp_debug_display,
}
}
90 changes: 47 additions & 43 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@
# [*wp_lang*]
# WordPress Localized Language. Default: ''
#
#
# [*wp_plugin_dir*]
# 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: ''
#
# [*wp_additional_inline_config*]
# Specifies a hash of additional configuration options to include near the end of the wp-config.php file. Default: '{}'
#
# [*wp_table_prefix*]
# Specifies the database table prefix. Default: wp_
#
Expand All @@ -73,50 +75,52 @@
define wordpress::instance (
$db_name,
$db_user,
$install_dir = $title,
$install_url = 'http://wordpress.org',
$version = '3.8',
$create_db = true,
$create_db_user = true,
$db_host = 'localhost',
$db_password = 'password',
$wp_owner = 'root',
$wp_group = '0',
$wp_lang = '',
$wp_config_content = undef,
$wp_plugin_dir = 'DEFAULT',
$wp_additional_config = 'DEFAULT',
$wp_table_prefix = 'wp_',
$wp_proxy_host = '',
$wp_proxy_port = '',
$wp_multisite = false,
$wp_site_domain = '',
$wp_debug = false,
$wp_debug_log = false,
$wp_debug_display = false,
$install_dir = $title,
$install_url = 'http://wordpress.org',
$version = '3.8',
$create_db = true,
$create_db_user = true,
$db_host = 'localhost',
$db_password = 'password',
$wp_owner = 'root',
$wp_group = '0',
$wp_lang = '',
$wp_config_content = undef,
$wp_plugin_dir = 'DEFAULT',
$wp_additional_config = 'DEFAULT',
$wp_additional_inline_config = {},
$wp_table_prefix = 'wp_',
$wp_proxy_host = '',
$wp_proxy_port = '',
$wp_multisite = false,
$wp_site_domain = '',
$wp_debug = false,
$wp_debug_log = false,
$wp_debug_display = false,
) {
wordpress::instance::app { $install_dir:
install_dir => $install_dir,
install_url => $install_url,
version => $version,
db_name => $db_name,
db_host => $db_host,
db_user => $db_user,
db_password => $db_password,
wp_owner => $wp_owner,
wp_group => $wp_group,
wp_lang => $wp_lang,
wp_config_content => $wp_config_content,
wp_plugin_dir => $wp_plugin_dir,
wp_additional_config => $wp_additional_config,
wp_table_prefix => $wp_table_prefix,
wp_proxy_host => $wp_proxy_host,
wp_proxy_port => $wp_proxy_port,
wp_multisite => $wp_multisite,
wp_site_domain => $wp_site_domain,
wp_debug => $wp_debug,
wp_debug_log => $wp_debug_log,
wp_debug_display => $wp_debug_display,
install_dir => $install_dir,
install_url => $install_url,
version => $version,
db_name => $db_name,
db_host => $db_host,
db_user => $db_user,
db_password => $db_password,
wp_owner => $wp_owner,
wp_group => $wp_group,
wp_lang => $wp_lang,
wp_config_content => $wp_config_content,
wp_plugin_dir => $wp_plugin_dir,
wp_additional_config => $wp_additional_config,
wp_additional_inline_config => $wp_additional_inline_config,
wp_table_prefix => $wp_table_prefix,
wp_proxy_host => $wp_proxy_host,
wp_proxy_port => $wp_proxy_port,
wp_multisite => $wp_multisite,
wp_site_domain => $wp_site_domain,
wp_debug => $wp_debug,
wp_debug_log => $wp_debug_log,
wp_debug_display => $wp_debug_display,
}

wordpress::instance::db { "${db_host}/${db_name}":
Expand Down
6 changes: 4 additions & 2 deletions manifests/instance/app.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$wp_config_content,
$wp_plugin_dir,
$wp_additional_config,
$wp_additional_inline_config,
$wp_table_prefix,
$wp_proxy_host,
$wp_proxy_port,
Expand All @@ -22,11 +23,12 @@
$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_hash($wp_additional_inline_config)
validate_bool($wp_multisite, $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) {
warning('When $wp_config_content is set, the following parameters are ignored: $wp_table_prefix, $wp_lang, $wp_debug, $wp_debug_log, $wp_debug_display, $wp_plugin_dir, $wp_proxy_host, $wp_proxy_port, $wp_multisite, $wp_site_domain, $wp_additional_config')
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 or $wp_additional_config or $wp_additional_inline_config) {
warning('When $wp_config_content is set, the following parameters are ignored: $wp_table_prefix, $wp_lang, $wp_debug, $wp_debug_log, $wp_debug_display, $wp_plugin_dir, $wp_proxy_host, $wp_proxy_port, $wp_multisite, $wp_site_domain, $wp_additional_config, $wp_additional_inline_config')
}

if $wp_multisite and ! $wp_site_domain {
Expand Down
12 changes: 12 additions & 0 deletions templates/wp-config.php.erb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ define('BLOG_ID_CURRENT_SITE', 1);
<% if @wp_additional_config != 'DEFAULT' -%>
<%= scope.function_template([@wp_additional_config]) %>
<% end -%>

<% if ! @wp_additional_inline_config.empty? %>
<% @wp_additional_inline_config.each do |key, value| %>
<% if value=='true' or value=='false' or value.class != String %>
define('<%=key%>', <%=value%>);
<% else %>
define('<%=key%>', '<%=value%>');
<% end %>
<% end%>
<% end %>


/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
Expand Down