]> git.openstreetmap.org Git - chef.git/commitdiff
Work around lack of support for lazy actions
authorTom Hughes <tom@compton.nu>
Sun, 17 Mar 2019 11:29:00 +0000 (11:29 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 17 Mar 2019 11:29:00 +0000 (11:29 +0000)
https://github.com/chef/chef/issues/3615

cookbooks/web/resources/rails_port.rb

index e3276da2c5b3c6e8bbfb933aacd535a65ded09b4..1aeac0139fbc19a171fe7c5a1ee723b86aba5d1c 100644 (file)
@@ -275,13 +275,20 @@ 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
+
+  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.slice(