X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/aeaa46f3071de018b5c5e0f5678cb5b4082e3ddc..145bccd7b212796f65b6fe3c98718bc90d7d272d:/cookbooks/mediawiki/resources/site.rb diff --git a/cookbooks/mediawiki/resources/site.rb b/cookbooks/mediawiki/resources/site.rb index e6c42df7f..424d4288a 100644 --- a/cookbooks/mediawiki/resources/site.rb +++ b/cookbooks/mediawiki/resources/site.rb @@ -24,8 +24,8 @@ property :aliases, :kind_of => [String, Array] property :directory, :kind_of => String property :version, :kind_of => String, :default => "1.33" property :database_name, :kind_of => String, :required => true -property :database_user, :kind_of => String, :required => true -property :database_password, :kind_of => String, :required => true +property :database_user, :kind_of => String, :required => [:create, :update] +property :database_password, :kind_of => String, :required => [:create, :update] property :sitename, :kind_of => String, :default => "OpenStreetMap Wiki" property :metanamespace, :kind_of => String, :default => "OpenStreetMap" property :logo, :kind_of => String, :default => "$wgStylePath/common/images/wiki.png" @@ -37,21 +37,23 @@ property :skin, :kind_of => String, :default => "vector" property :site_notice, :kind_of => [String, TrueClass, FalseClass], :default => false property :site_readonly, :kind_of => [String, TrueClass, FalseClass], :default => false property :admin_user, :kind_of => String, :default => "Admin" -property :admin_password, :kind_of => String, :required => true +property :admin_password, :kind_of => String, :required => [:create] property :private_accounts, :kind_of => [TrueClass, FalseClass], :default => false property :private_site, :kind_of => [TrueClass, FalseClass], :default => false property :recaptcha_public_key, :kind_of => String property :recaptcha_private_key, :kind_of => String property :extra_file_extensions, :kind_of => [String, Array], :default => [] +property :fpm_max_children, :kind_of => Integer, :default => 5 +property :fpm_request_terminate_timeout, :kind_of => Integer, :default => 300 property :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true action :create do - node.normal_unless[:mediawiki][:sites][new_resource.site] = {} + node.default[:mediawiki][:sites][new_resource.site] = { + :directory => site_directory, + :version => new_resource.version + } - node.normal[:mediawiki][:sites][new_resource.site][:directory] = site_directory - node.normal[:mediawiki][:sites][new_resource.site][:version] = new_resource.version - - node.normal_unless[:mediawiki][:sites][new_resource.site][:wgSecretKey] = SecureRandom.base64(48) + secret_key = persistent_token("mediawiki", new_resource.site, "wgSecretKey") mysql_user "#{new_resource.database_user}@localhost" do password new_resource.database_password @@ -171,7 +173,8 @@ action :create do variables :name => new_resource.site, :directory => mediawiki_directory, :database_params => database_params, - :mediawiki => mediawiki_params + :mediawiki => mediawiki_params, + :secret_key => secret_key notifies :run, "execute[#{mediawiki_directory}/maintenance/update.php]" end @@ -517,6 +520,16 @@ action :create do domains [new_resource.site] + Array(new_resource.aliases) end + php_fpm new_resource.site do + pm_max_children new_resource.fpm_max_children + request_terminate_timeout new_resource.fpm_request_terminate_timeout + php_admin_values "open_basedir" => "#{site_directory}/:/usr/share/php/:/dev/null:/tmp/" + php_values "memory_limit" => "500M", + "max_execution_time" => "240", + "upload_max_filesize" => "70M", + "post_max_size" => "100M" + end + apache_site new_resource.site do cookbook "mediawiki" template "apache.erb" @@ -582,6 +595,8 @@ action :delete do end action_class do + include Chef::Mixin::PersistentToken + def site_directory new_resource.directory || "/srv/#{new_resource.site}" end