motd.rb |
|
---|---|
Creates a custom Message Of The Day when a user logs in. A little too trivial, but you can see some of Chef’s parts nonetheless. |
|
The file resource manages a file an optionally its contents. In
this case we’re setting the contents of the file with the For more details about how this resource works, consult the Chef resources wiki page. |
file "/etc/motd.tail" do |
This will be the owner of the file. We’re being a bit explicit here. |
owner "root" |
This will be the group ownership of the file. Woah. |
group "root" |
This is the default action, to create the file. Other possible
actions are |
action :create |
The contents of our file. The |
content <<-MOTD.gsub(/^ {4}/, '')
============================================================
Hello, World!
Welcome to #{node[:fqdn]} running #{node[:platform].capitalize}
Your server is being tenderly cared for thanks to Chef
version #{node[:chef_packages][:chef][:version]}.
Enjoy yourself, and use all #{node[:memory][:total]} of your RAM.
============================================================
MOTD
end |