Information Technology Reference
In-Depth Information
four possible actions:
:install
,
:upgrade
,
:remove
, and
:purge
. Because
:install
is the
default, we don't need to specify the action. Let's change our recipe accordingly, as shown in
Example 7-11. chefdk/apache/recipes/default.rb
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright (C) 2014
#
#
#
package
"httpd"
Now the
package
reference is a lot more concise, and it performs the same action. Look for
opportunities to make use of default actions where possible.
Introducing the Service Resource
Next, let's use the
service
resource to start the
httpd
service and automatically enable it on
restart. The
service
resource can start a service with the
:start
action, and it can enable a
service at boot with the
:enable
action.
You can pass more than one action to the
service
resource by passing them as an array. In
Chapter 3
we discussed how an array is a delimited list of comma-delimited items contained
within square brackets (
[]
).
Example 7-12. chefdk/apache/recipes/default.rb
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright (C) 2014
#
#
#