Information Technology Reference
In-Depth Information
The
hostname of this node is
<
%= node['hostname'] %>
The IP address of this node is <%=
node
[
'ipaddress'
] %>
Perform a
kitchen converge
to apply the cookbook to your node, and then when you run
kitchen login
it should display the following, with the expected values for
node["ipaddress"]
and
node["hostname"]
. (Reminder: Once you have issued these com-
mands and verified the output is correct, make sure you run the
exit
command to get back to
the host prompt directory with your cookbook source.)
$
kitchen converge
$
kitchen login
Last login: Sun Jul 20 19:40:55 2014 from 10.0.2.2
The hostname of this node is default-centos65
The IP address of this node is 10.0.2.15
[vagrant@default-centos65 ~]$
exit
logout
Connection to 127.0.0.1 closed.
NOTE
If the last line with the IP address is missing, even though it is clearly in the
motd.erb
, add
an extra newline in your text editor at the end of the file. The message of the day won't
display the last line if it does not have a carriage return in the text.
Setting Attributes
Now, let's try setting some attributes in our cookbook. First, generate a default attributes file.
Chef Development Kit:
$
chef generate attribute default
Chef Client - Linux/Mac OS X:
$
touch attributes/default.rb
Chef Client - Windows: