+ notifies :restart, "passenger_application[#{rails_directory}]"
+ 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",
+ "tile_cdn_url"
+ ).compact.merge(
+ "server_protocol" => "https",
+ "server_url" => new_resource.site,
+ "support_email" => "support@openstreetmap.org",
+ "email_return_path" => "bounces@openstreetmap.org",
+ "geonames_username" => "openstreetmap",
+ "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 "664"
+ content YAML.dump(settings)
+ 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 "664"
+ content YAML.dump(storage_configuration)