Skip to content
Snippets Groups Projects
Commit 122772b3 authored by Fabien Combernous's avatar Fabien Combernous
Browse files

Merge branch '42-modifying-value-of-title-in-data-modifies-noting' into 'master'

Resolve "Modifying value of title in data modifies noting."

Closes #42

See merge request !38
parents 83f716b4 b4413953
No related branches found
No related tags found
1 merge request!38Resolve "Modifying value of title in data modifies noting."
#
# @summary Configure an option in the desired state
#
define wordpress::config::option(
String $wp_servername,
String $wp_root,
String $owner,
String $wp_option_name,
String $wp_option_value,
String $wpcli_bin,
) {
exec { "${wp_servername} > update ${wp_option_name}" :
command => "${wpcli_bin} option update ${wp_option_name} '${wp_option_value}'",
cwd => $wp_root,
user => $owner,
unless => "${wpcli_bin} option get ${wp_option_name} | /bin/grep -q '^${wp_option_value}'",
}
}
......@@ -106,12 +106,30 @@ class wordpress (
settings => $settings,
wpcli_bin => $wpcli_bin,
wparchives_path => $wparchives_path,
require => [
Class[wordpress::cli],
],
}
->
# then manage others resources like plugins and themes
class { 'wordpress::resource' :
settings => $settings,
wpcli_bin => $wpcli_bin,
require => [
Class[wordpress::cli],
Class[wordpress::core],
],
}
# and finaly set options of sites
class { 'wordpress::site' :
settings => $settings,
wpcli_bin => $wpcli_bin,
require => [
Class[wordpress::cli],
Class[wordpress::core],
Class[wordpress::resource],
],
}
# manage external_fact wordpress
......
#@summary Use WP-CLI to download last version of WordPress core, create tables in database and configure WordPress.
#
#@param wpcli_bin
# The PATH where the WP-CLI tools is deployed.
#
#@param wparchives_path
# Gives the path where are stored archives done before update managed by puppet (not by WordPress itself with `wpselfupdate`). Defaults to /var/wordpress_archives.
#
#@param settings
# Describes all availables settings in this module for all wordpress instances on this node. Defaults to empty hash.
#
#@note This class should be considered as private.
class wordpress::site (
Pattern['^/'] $wpcli_bin,
Wordpress::Settings $settings = {},
) {
$settings.each | String $_wp_servername , Hash $_wp_configs | {
# use some defaults if not provided
$_ensure = $_wp_configs['ensure'] ? {
Enum['present','absent','latest'] => $_wp_configs['ensure'],
default => 'present',
}
$_owner = $_wp_configs['owner'] ? {
String => $_wp_configs['owner'],
default => $::wordpress::params::default_wpowner,
}
if $_ensure == 'present' or $_ensure == 'latest' {
wordpress::config::option { "${_wp_servername} > set title" :
wp_servername => $_wp_servername,
wp_root => $_wp_configs['wproot'],
owner => $_owner,
wp_option_name => 'blogname',
wp_option_value => $_wp_configs['wptitle'],
wpcli_bin => $wpcli_bin,
}
}
}
}
......@@ -118,7 +118,7 @@ describe 'wordpress class' do
end
end
context 'with parameter about one wordpress with customs plugins and themes' do
context 'with parameters about one wordpress with customs plugins and themes' do
it 'applies idempotently' do
pp = <<-EOS
class { 'wordpress':
......@@ -203,6 +203,35 @@ describe 'wordpress class' do
end
end
context 'with new title' do
it 'applies idempotently' do
pp = <<-EOS
class { 'wordpress':
settings => {
'wordpress.foo.org' => {
owner => 'wp',
dbhost => '127.0.0.1',
dbname => 'wordpress',
dbuser => 'wpuserdb',
dbpasswd => 'kiki',
wproot => '/var/www/wordpress.foo.org',
wptitle => 'hola this is modified',
wpadminuser => 'wpadmin',
wpadminpasswd => 'lolo',
wpadminemail => 'bar@foo.org',
}
}
}
EOS
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe command('curl -L http://localhost') do
its(:stdout) { should match /.*hola this is modified.*/ }
end
end
context 'with parameters about two wordpress instances with customs locales and archives path' do
it 'applies idempotently' do
pp = <<-EOS
......
require 'spec_helper'
describe 'wordpress::site' do
let :params do
{
wpcli_bin: '/bin/wpcli',
}
end
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
it { is_expected.to compile }
end
end
end
require 'spec_helper'
describe 'wordpress::config::option' do
let(:title) { 'namevar' }
let(:params) do
{
wp_servername: 'www.foo.org',
wp_root: '/var/foo',
owner: 'wfoo',
wp_option_name: 'fooname',
wp_option_value: 'foovalue',
wpcli_bin: '/bin/wp',
}
end
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
it { is_expected.to compile }
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment