This is a resource that actually lets us to execute some script or some contents of a script inside of our actual Chef recipes. It provides compatibility across multiple Unix systems.
Example1: execute with inline script
execute "run a script" do
user "root"
command <<-EOL
mkdir -p /var/www/mysites/
chown -R www-data /var/www/mysites
EOL
not_if do
File.directory?('/var/www/mysites')
end
end
execute "run script"
user "root"
command "./myscript.sh"
not_if
...
end
directory "/var/www/mysites" do
owner "www-data"
recursive true
mode ...
end