Chef package

Chef is a powerful configuration management tool that turns infrastructure into code. With the help of Chef, Users can easily manage, configure and deploy the resources across the network from the central location of the environment (cloud, on-premises, or hybrid).

Use the package resource to manage packages. When the package is installed from a local file (such as with RubyGems, dpkg, or RPM Package Manager), the file must be added to the node using the remote_file or cookbook_file resources.

A package resource block manages a package on a node, typically by installing it. The simplest use of the package resource is:

Syntax

package 'httpd'

which will install Apache using all of the default options and the default action (:install).

For a package that has different package names, depending on the platform, use a case statement within the package:

package 'Install Apache' do

case node[:platform]

when 'redhat', 'centos'

package_name 'httpd'

when 'ubuntu', 'debian'

package_name 'apache2'

end

end

where 'redhat', 'centos' will install Apache using the httpd package and 'ubuntu, 'Debian will install it using the apache2 package

The full syntax for all of the properties that are available to the package resource is:

package 'name' do

allow_downgrade TrueClass, FalseClass # Yum, RPM packages only

arch String, Array # Yum packages only

default_release String # Apt packages only

flush_cache Array

gem_binary String

homebrew_user String, Integer # Homebrew packages only

notifies # see description

options String

package_name String, Array # defaults to 'name' if not specified

provider Chef::Provider::Package

response_file String # Apt packages only

response_file_variables Hash # Apt packages only

source String

subscribes # see description

timeout String, Integer

version String, Array

action Symbol # defaults to :install if not specified

end

where

*package tells the chef-client to manage a package; the chef-client will determine the correct package provider to use based on the platform running on the node

*'name' is the name of the package

*:action identifies which steps the chef-client will take to bring the node into the desired state allow_downgrade, arch, default_release, flush_cache, gem_binary, homebrew_user, options, package_name, provider, response_file, response_file_variables, source, recursive, timeout, and version are properties of this resource, with the Ruby type shown. See the “Properties” section below for more information about all of the properties that may be used with this resource.

Recent Comments

No comments

Leave a Comment