Information Technology Reference
In-Depth Information
_________________________________________________
< YOU ARE ON A SIMULATED CHEF NODE ENVIRONMENT! >
-----------------------------------------------
\ ^__^
\ (oo)\_______
(__))\/\ \
||----w |
|| ||
Introducing the Cookbook_file Resource
We'll use Chef to help us more easily determine that we are running on a guest virtual ma-
chine node by writing some automation to change the Linux message of the day . On Linux,
the message of the day is displayed when a user logs in. The message of the day is used by
Linux administrators to communicate with users. You can change the message of the day by
editing the file /etc/motd . When a user successfully logs in, the contents of the /etc/motd file
will be displayed as the message of the day.
knife cookbook create generates a recipes/default.rb file for you. By convention, this is
the default location for your Chef code. All recipe .rb files containing Chef code are expec-
ted to be in the recipes/ subdirectory of a cookbook.
#
# Cookbook Name:: motd
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
Add some Chef code to change the /etc/motd on your node by editing recipes/default.rb to
resemble Example 7-6 (we'll leave it as an exercise to the reader to modify the copyright and
licensing text in the comments later).
Example 7-6. knife/motd/recipes/default.rb
#
# Cookbook Name:: motd
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
Search WWH ::




Custom Search