Ori.livneh has uploaded a new change for review. https://gerrit.wikimedia.org/r/71659
Change subject: Manage configuration fragments in rc.d-like dir ...................................................................... Manage configuration fragments in rc.d-like dir One of the pain-points with MediaWiki-Vagrant is the way it handles MediaWiki configuration files. settings/README encourages you to add your own configuration fragments to settings/*, and if you take the advice you end up with a directory of PHP files, some of which are managed by Puppet and some of which are not. This is confusing. An even more severe problem is the fact that disabling a role (i.e., commenting it back out in site.pp) does nothing. Puppet stops managing the files that are associated with the role, but they are left in-place. This becomes especially problematic when the machine is torn down and recreated, because the globbing and loading of settings/* means that MediaWiki could try and load leftover configuration files from a previous instance. This change improves things somewhat. First, it renames settings/ to settings.d/, which serves as a hint for people that are familiar with rc.d style config.d directories. Second, it relegates all the settings files that are managed by Puppet to settings.d/puppet-managed. Third, it configures Puppet to purge unmanaged files from the directory on each run. This means that the state of the directory is always in-sync with what is enabled in Puppet. The Puppet pattern I used is described here: <http://christian.hofstaedtler.name/blog/2008/11/puppet-managing-directories-recursively.html>. Change-Id: I136c46a967183239ba3567767118a0f1692a39fd --- M .gitignore M LocalSettings.php M puppet/manifests/roles.pp M puppet/manifests/site.pp A puppet/modules/mediawiki/files/mediawiki-settings.d-empty/README M puppet/modules/mediawiki/manifests/extension.pp M puppet/modules/mediawiki/manifests/init.pp R settings.d/10-VisualEditor.php-sample R settings.d/README A settings.d/puppet-managed/README D settings/.gitignore 11 files changed, 60 insertions(+), 34 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant refs/changes/59/71659/1 diff --git a/.gitignore b/.gitignore index ed1b50a..04b834b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ .vagrant /Vagrantfile-extra.rb /LocalSettings.php -tags /mediawiki/ +/settings.d +!/settings.d/README +!/settings.d/10-VisualEditor.php-sample +!/settings.d/puppet-managed/README diff --git a/LocalSettings.php b/LocalSettings.php index c15ea9e..74b2c7e 100644 --- a/LocalSettings.php +++ b/LocalSettings.php @@ -3,8 +3,8 @@ * MediaWiki configuration * * To customize your MediaWiki instance, you may change the content of this - * file. See settings/README for an alternate way of managing small snippets of - * configuration data, such as extension invocations. + * file. See settings.d/README for an alternate way of managing small snippets + * of configuration data, such as extension invocations. * * This file is part of Mediawiki-Vagrant. */ @@ -59,9 +59,9 @@ } } -// Load configuration snippets from ./settings. See settings/README. -foreach( glob( __DIR__ . '/settings/*.php' ) as $snippet ) { - if ( !include_once( $snippet ) ) { - echo "Failed to load \"$snippet\".\n"; - } +// Load configuration fragments from /vagrant/settings.d +foreach( array_merge( + glob( __DIR__ . '/settings.d/*.php' ) + glob( __DIR__ . '/settings.d/puppet-managed/*.php' ) ) as $conffile ) { + include_once $conffile; } diff --git a/puppet/manifests/roles.pp b/puppet/manifests/roles.pp index 80e130f..c1a05c4 100644 --- a/puppet/manifests/roles.pp +++ b/puppet/manifests/roles.pp @@ -33,6 +33,7 @@ # changing the value of 'FORWARDED_PORT' in Vagrantfile. $server_url = "http://127.0.0.1:${::forwarded_port}" $dir = '/vagrant/mediawiki' + $settings_dir = '/vagrant/settings.d' $upload_dir = '/srv/images' # Database access @@ -52,15 +53,16 @@ } class { '::mediawiki': - wiki_name => $wiki_name, - admin_user => $admin_user, - admin_pass => $admin_pass, - db_name => $db_name, - db_pass => $db_pass, - db_user => $db_user, - dir => $dir, - upload_dir => $upload_dir, - server_url => $server_url, + wiki_name => $wiki_name, + admin_user => $admin_user, + admin_pass => $admin_pass, + db_name => $db_name, + db_pass => $db_pass, + db_user => $db_user, + dir => $dir, + settings_dir => $settings_dir, + upload_dir => $upload_dir, + server_url => $server_url, } } diff --git a/puppet/manifests/site.pp b/puppet/manifests/site.pp index f4df0bd..abac8f1 100644 --- a/puppet/manifests/site.pp +++ b/puppet/manifests/site.pp @@ -23,17 +23,17 @@ node 'mediawiki-vagrant' { include role::mediawiki - # include role::fundraising - # include role::scribunto - # include role::wikieditor - # include role::proofreadpage - # include role::uploadwizard - # include role::visualeditor # include role::browsertests # include role::echo # include role::eventlogging + # include role::fundraising # include role::gettingstarted # include role::mobilefrontend - # include role::umapi + # include role::proofreadpage # include role::remote_debug + # include role::scribunto + # include role::umapi + # include role::uploadwizard + # include role::visualeditor + # include role::wikieditor } diff --git a/puppet/modules/mediawiki/files/mediawiki-settings.d-empty/README b/puppet/modules/mediawiki/files/mediawiki-settings.d-empty/README new file mode 100644 index 0000000..9b084e8 --- /dev/null +++ b/puppet/modules/mediawiki/files/mediawiki-settings.d-empty/README @@ -0,0 +1,2 @@ +This directory contains MediaWiki configuration fragments that are managed by Puppet. +PUPPET WILL PURGE ANY UNMANAGED FILES IN THIS DIRECTORY WITHOUT WARNING. diff --git a/puppet/modules/mediawiki/manifests/extension.pp b/puppet/modules/mediawiki/manifests/extension.pp index 6f66613..8cbaf67 100644 --- a/puppet/modules/mediawiki/manifests/extension.pp +++ b/puppet/modules/mediawiki/manifests/extension.pp @@ -83,12 +83,15 @@ include mediawiki $extension_dir = "${mediawiki::dir}/extensions/${extension}" + @git::clone { "mediawiki/extensions/${extension}": directory => $extension_dir, } - $settings_file = sprintf('%.2d-%s.php', $priority, $extension) - file { "/vagrant/settings/${settings_file}": + $settings_file = sprintf('%s/%.2d-%s.php', + $mediawiki::managed_settings_dir, $priority, $extension) + + file { $settings_file: ensure => $ensure, content => template('mediawiki/extension-loader.php.erb'), # Because the file resides on a shared folder, any other owner @@ -102,6 +105,6 @@ if $needs_update { # If the extension requires a schema migration, set up the # setting file resource to notify update.php. - File["/vagrant/settings/${settings_file}"] ~> Exec['update database'] + File[$settings_file] ~> Exec['update database'] } } diff --git a/puppet/modules/mediawiki/manifests/init.pp b/puppet/modules/mediawiki/manifests/init.pp index 19fc79c..fe87450 100644 --- a/puppet/modules/mediawiki/manifests/init.pp +++ b/puppet/modules/mediawiki/manifests/init.pp @@ -27,6 +27,10 @@ # The system path to which MediaWiki files have been installed # (example: '/srv/mediawiki'). # +# [*settings_dir*] +# Directory to use for configuration fragments. +# (example: '/srv/mediawiki/settings.d'). +# # [*upload_dir*] # The file system path of the folder where files will be uploaded # (example: '/srv/mediawiki/images'). @@ -42,6 +46,7 @@ $db_pass, $db_user, $dir, + $settings_dir, $upload_dir, $server_url, ) { @@ -51,6 +56,8 @@ include mediawiki::phpsh include mediawiki::apache + + $managed_settings_dir = "${settings_dir}/puppet-managed" @git::clone { 'mediawiki/core': directory => $dir, @@ -66,11 +73,22 @@ unless => "php ${dir}/maintenance/sql.php </dev/null", } - file { $upload_dir: + file { [ $upload_dir, $settings_dir ]: ensure => directory, owner => 'vagrant', group => 'www-data', - mode => '0775', + mode => '0755', + } + + file { "${settings_dir}/puppet-managed": + ensure => directory, + owner => undef, + group => undef, + mode => undef, + recurse => true, + purge => true, + force => true, + source => 'puppet:///modules/mediawiki/mediawiki-settings.d-empty', } exec { 'mediawiki setup': diff --git a/settings/10-VisualEditor.php-sample b/settings.d/10-VisualEditor.php-sample similarity index 100% rename from settings/10-VisualEditor.php-sample rename to settings.d/10-VisualEditor.php-sample diff --git a/settings/README b/settings.d/README similarity index 94% rename from settings/README rename to settings.d/README index 885480f..dc02296 100644 --- a/settings/README +++ b/settings.d/README @@ -16,7 +16,7 @@ | | | to share settings with others. | ; | | /| \ This directory is accessible as - | _/ T / '/vagrant/settings' in the guest environment. + | _/ T / '/vagrant/settings.d' in the guest environment. | | | | | | |__|_ Because the files load alphabeticallly, you can use a |__| '-.__) two-digit prefix to tweak the load order -- e.g.: diff --git a/settings.d/puppet-managed/README b/settings.d/puppet-managed/README new file mode 100644 index 0000000..9b084e8 --- /dev/null +++ b/settings.d/puppet-managed/README @@ -0,0 +1,2 @@ +This directory contains MediaWiki configuration fragments that are managed by Puppet. +PUPPET WILL PURGE ANY UNMANAGED FILES IN THIS DIRECTORY WITHOUT WARNING. diff --git a/settings/.gitignore b/settings/.gitignore deleted file mode 100644 index 078b995..0000000 --- a/settings/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!.gitignore -!README -!10-VisualEditor.php-sample -- To view, visit https://gerrit.wikimedia.org/r/71659 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I136c46a967183239ba3567767118a0f1692a39fd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/vagrant Gerrit-Branch: master Gerrit-Owner: Ori.livneh <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
