X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/9ea48dbd10bd416e75abfb8fc10eb1b1c8f11842..41b58359dc0299859f28f5e93d64d171db89ab26:/cookbooks/web/resources/rails_port.rb diff --git a/cookbooks/web/resources/rails_port.rb b/cookbooks/web/resources/rails_port.rb index e3276da2c..de6f97ad8 100644 --- a/cookbooks/web/resources/rails_port.rb +++ b/cookbooks/web/resources/rails_port.rb @@ -244,14 +244,6 @@ action :create do line.gsub!(/^( *)#wikipedia_auth_secret:.*$/, "\\1wikipedia_auth_secret: \"#{new_resource.wikipedia_auth_secret}\"") end - if new_resource.mapquest_key - line.gsub!(/^( *)#mapquest_key:.*$/, "\\1mapquest_key: \"#{new_resource.mapquest_key}\"") - end - - if new_resource.mapzen_valhalla_key - line.gsub!(/^( *)#mapzen_valhalla_key:.*$/, "\\1mapzen_valhalla_key: \"#{new_resource.mapzen_valhalla_key}\"") - end - if new_resource.thunderforest_key line.gsub!(/^( *)#thunderforest_key:.*$/, "\\1thunderforest_key: \"#{new_resource.thunderforest_key}\"") end @@ -275,23 +267,29 @@ action :create do line end - file "#{rails_directory}/config/application.yml" do - action(lazy { File.exist?("#{rails_directory}/config/example.application.yml") ? :create : :delete }) + file "create:#{rails_directory}/config/application.yml" do + path "#{rails_directory}/config/application.yml" owner new_resource.user group new_resource.group mode 0o664 content application_yml notifies :run, "execute[#{rails_directory}/public/assets]" + only_if { ::File.exist?("#{rails_directory}/config/example.application.yml") } end - settings = new_resource.slice( + file "delete:#{rails_directory}/config/application.yml" do + path "#{rails_directory}/config/application.yml" + action :delete + not_if { ::File.exist?("#{rails_directory}/config/example.application.yml") } + end + + settings = new_resource.to_hash.transform_keys(&:to_s).slice( "email_from", "status", "messages_domain", "attachments_dir", "log_path", "logstash_path", - "memcache_servers", "potlatch2_key", "id_key", "oauth_key", @@ -312,7 +310,7 @@ action :create do "totp_key", "csp_enforce", "csp_report_url" - ).merge( + ).reject { |_k, v| v.nil? }.merge( "server_protocol" => "https", "server" => new_resource.site, "publisher_url" => "https://plus.google.com/111953119785824514010", @@ -323,6 +321,10 @@ action :create do "trace_use_job_queue" => false ) + if new_resource.memcache_servers + settings["memcache_servers"] = new_resource.memcache_servers.to_a + end + if new_resource.gpx_dir settings["gpx_trace_dir"] = "#{new_resource.gpx_dir}/traces" settings["gpx_image_dir"] = "#{new_resource.gpx_dir}/images" @@ -334,7 +336,7 @@ action :create do mode 0o664 content YAML.dump(settings) notifies :run, "execute[#{rails_directory}/public/assets]" - only_if { File.exist?("#{rails_directory}/config/settings.yml") } + only_if { ::File.exist?("#{rails_directory}/config/settings.yml") } end if new_resource.piwik_configuration