+ only_if { ::File.exist?("#{rails_directory}/config/example.application.yml") }
+ end
+
+ 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",
+ "potlatch2_key",
+ "id_key",
+ "oauth_key",
+ "nominatim_url",
+ "osrm_url",
+ "google_auth_id",
+ "google_auth_secret",
+ "google_openid_realm",
+ "facebook_auth_id",
+ "facebook_auth_secret",
+ "windowslive_auth_id",
+ "windowslive_auth_secret",
+ "github_auth_id",
+ "github_auth_secret",
+ "wikipedia_auth_id",
+ "wikipedia_auth_secret",
+ "thunderforest_key",
+ "totp_key",
+ "csp_enforce",
+ "csp_report_url",
+ "trace_use_job_queue",
+ "diary_feed_delay",
+ "storage_service",
+ "storage_url"
+ ).reject { |_k, v| v.nil? }.merge(
+ "server_protocol" => "https",
+ "server_url" => new_resource.site,
+ "support_email" => "support@openstreetmap.org",
+ "email_return_path" => "bounces@openstreetmap.org",
+ "geonames_username" => "openstreetmap",
+ "geoip_database" => "/usr/share/GeoIP/GeoIPv6.dat",
+ "maxmind_database" => "/usr/share/GeoIP/GeoLite2-Country.mmdb"
+ )
+
+ 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"
+ end
+
+ file "#{rails_directory}/config/settings.local.yml" do
+ owner new_resource.user
+ group new_resource.group
+ mode 0o664
+ content YAML.dump(settings)
+ notifies :run, "execute[#{rails_directory}/public/assets]"
+ only_if { ::File.exist?("#{rails_directory}/config/settings.yml") }
+ end
+
+ storage_configuration = new_resource.storage_configuration.merge(
+ "local" => {
+ "service" => "Disk",
+ "root" => "#{rails_directory}/storage"
+ }
+ )
+
+ file "#{rails_directory}/config/storage.yml" do
+ owner new_resource.user
+ group new_resource.group
+ mode 0o664
+ content YAML.dump(storage_configuration)
+ notifies :run, "execute[#{rails_directory}/public/assets]"