Information Technology Reference
In-Depth Information
Performing another Chef run and checking the message of the day should produce the fol-
lowing output (again, make sure to exit back out to the host prompt):
$ kitchen converge
$ kitchen login
Last login: Sun Jul 20 19:52:53 2014 from 10.0.2.2
Welcome to Chef
It's a wonderful day today!
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.
Basic Attribute Priority
Now let's experiment with the basics of attribute priorities by trying to reset values set else-
where. As shown in Example 8-7 , modify the recipe/default.rb so that it tries to reset the
value of a higher priority automatic attribute set by ohai , and a lower priority attribute
defined in the attribute file.
Example 8-7. chefdk/motd-attributes/recipes/default.rb
node . default [ 'ipaddress' ] = '1.1.1.1'
node . default [ 'motd-attributes' ][ 'company' ] = 'My Company'
node . default [ 'motd-attributes' ][ 'message' ] = "It's a wonderful day today!"
template '/etc/motd' ddo
source 'motd.erb'
mode "0644"
end
end
Perform a Chef run and check to see the resulting values:
$ kitchen converge
$ kitchen login
Last login: Sun Jul 20 20:05:38 2014 from 10.0.2.2
Welcome to My Company
It's a wonderful day today!
The hostname of this node is default-centos65
The IP address of this node is 10.0.2.15
[vagrant@default-centos65 ~]$ exit
Search WWH ::




Custom Search