Information Technology Reference
In-Depth Information
package "httpd"
service "httpd" ddo
action [ :enable , :start ]
end
end
This is the first time we've encountered multiple resources in one recipe. Chef evaluates the
recipes as you would expect—in the order they are listed in the file.
Let's run kitchen converge again and log in to verify that our cookbook produced the in-
tended result:
$ kitchen converge default-centos65
$ kitchen login default-centos65
Last login: Thu Aug 14 13:50:39 2014 from 10.0.2.2
Welcome to your Packer-built virtual machine.
[vagrant@default-centos65 ~]$ chkconfig --list httpd | grep 3:on
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[vagrant@default-centos65 ~]$ exit
logout
Connection to 127.0.0.1 closed.
Our service is enabled! For CentOS and other Redhat variants, services are enabled in differ-
ent run levels. Our service should be enabled for runlevel 3, which is multi-user text mode
with networking enabled—the default for a working CentOS server running in text mode. In
our grep statement, we verified that the service is set to be on for runlevel 3.
Introducing the Template Resource
We'll introduce the template resource by showing you how to generate the file containing
the content for our website. The template resource is similar to cookbook_file in that it cre-
ates a file on the node. However, a template has the additional ability to expand variable ref-
erences to the file and other statements in the form of Embedded RuBy (ERB).
Let's add the resource statement to recipes/default.rb as shown in Example 7-13 .
Example 7-13. chefdk/apache/recipes/default.rb
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright (C) 2014
Search WWH ::




Custom Search