Created
March 6, 2013 18:22
-
-
Save charlesjohnson/5101696 to your computer and use it in GitHub Desktop.
Copy a file in Chef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node.default["copy_file"]["source"] = '/root/foo' | |
node.default["copy_file"]["destination"] = '/tmp/foonew' | |
file node["copy_file"]["source"] do | |
action :create | |
content "This is a file created by Chef!\n" | |
owner "root" | |
group "root" | |
mode "0644" | |
end | |
ruby_block "copy file" do | |
block do | |
::FileUtils.cp node["copy_file"]["source"], node["copy_file"]["destination"] | |
end | |
if ::File.exist?( node["copy_file"]["destination"]) | |
not_if { ::FileUtils.compare_file("/tmp/vagrant-chef-1/client.rb", "/etc/chef/client.rb") } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment