Syntax

The manifest file is taken up with declaring resources which can be grouped into classes. The manifest file uses a domain-specific language called Puppet, which is similar to YAML or Ruby (when writing a Vagrantfile).

Here is an example manifest that installs and runs the nginx web server. Let's create a new manifest and call it  nginx.pp:

package { "nginx":
ensure => installed
}

service { "nginx":
require => Package["nginx"],
ensure => running,
enable => true
}

There are a few things to note in the preceding example. Each resource (section) starts with the category. We are using two categories package and service. In a resource block, we wrap the values within curly parentheses, {}, and we then reference the name (nginx) and set the values we require. 

There are a few keywords that we are using in the resource blocks  ensure, require, and enable. These keywords help describe what should happen for the node to reach a desired state. The ensure keyword is used to ensure that the package or service is doing what you want it to, such as installing or running. The require keyword is used when a specific resource relies on another resource. In the service resource, we are using the keyword enable, which allows us to specify if a service is active or not. It can be useful if you need to temporarily disable a service while testing.

You can add comments into the manifest file by using the hashtag/pound symbol. The following is an example:

# This comment wont be parsed by Puppet but it will be useful for other developers/DevOps

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.157.45