Skip to content

Instantly share code, notes, and snippets.

@charlesjohnson
Created March 6, 2013 18:22
Show Gist options
  • Save charlesjohnson/5101696 to your computer and use it in GitHub Desktop.
Save charlesjohnson/5101696 to your computer and use it in GitHub Desktop.
Copy a file in Chef
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