Metaparameter reference
Metaparameters are attributes that work with any resource type, including custom types and defined types. They change the way Puppet handles resources.
- Add metadata to a resource with the
alias
ortag
metaparameters. - Set limits on when the resource should be applied, by using relationship
metaparameters like
notify
orrequire
. - Prevent Puppet from making changes, by
setting the
noop
metaparameter. - Change logging verbosity with the
loglevel
metaparameter.
alias
Creates an alias for the resource. You can explicitly specify the alias metaparameter, but it's usually safer to give the resource the alias value as the title and provide the full namevar value explicitly.
sshdconfig
, which acts as the alias. The namevar value is the path,
which is set to '/etc/ssh/sshd_config'
.file { 'sshdconfig':
path => '/etc/ssh/sshd_config',
source => '...'
}
service { 'sshd':
subscribe => File['sshdconfig'],
}
file { '/etc/ssh/sshd_config':
owner => root,
group => root,
alias => 'sshdconfig',
}
File['sshdconfig'] {
mode => '0644',
}
audit
Marks a subset of this resource's unmanaged attributes for auditing. Accepts an
attribute name, an array of attribute names, or the value all
.
When audit is set for an attribute, when Puppet applies the catalog, it checks whether that attribute of the resource has been modified, comparing its current value to the previous run. Any change is then logged alongside any actions Puppet performed while applying the catalog.
before
Specifies one or more resources that depend on this resource, expressed as resource
references. Specify multiple resources as an array of references. When specified,
before
causes the resource to be applied before
the dependent resources. This is one of the four relationship metaparameters, along
with require
, notify
, and subscribe
. For more
information about creating relationships between resources, see Relationships and ordering. For details about resource references, see
Resource and class references.
loglevel
emerg
alert
crit
err
warning
notice
info
verbose
debug
noop
Whether to apply this resource in non-operational, or "no-op" mode. When applying a
resource in noop
mode, Puppet checks whether the resource is in the desired
state as declared in the catalog. If the resource is not in the desired state, Puppet takes no action, but reports the changes it
would have made. These simulated changes appear in the report sent to the primary
server or are displayed be shown on the console if running puppet agent or puppet
apply in the foreground. The simulated changes do not send refresh events to any
subscribing or notified resources, although Puppet
logs that a refresh event would have been sent. Valid values are true
or false
.
noop
metaparameter on
individual resources. That is, the value of a global noop
setting affects only resources that do not have an explicit
value set for their noop
attribute. notify
Specifies one or more resources that depend on this resource, expressed as resource references. Specify multiple resources as an array of references.
When this attribute is set, this resource is applied before the notified resources. If Puppet makes changes to this resource, it causes all of the notified resources to refresh. Refresh behavior varies by resource type: for example, services restart and mounts unmount and re-mount. Not all types can refresh.
This is one of the four relationship metaparameters, along with before
, require
, and
subscribe
. For more information about creating
relationships between resources, see Relationships and ordering. For
details about resource references, see Resource and class references.
require
Specifies one or more resources that this resource depends on, expressed as resource references. Specify multiple resources as an array of references.
When this attribute is set, the required resources are applied before this resource.
This is one of the four relationship metaparameters, along with before
, notify
, and
subscribe
. For more information about creating
relationships between resources, see Relationships and ordering. For
details about resource references, see Resource and class references.
schedule
A schedule to govern when Puppet is allowed to manage
this resource. The value of this metaparameter must be the name
of a schedule
resource. This
means you must first declare a schedule resource, then refer to it by name.
schedule { 'everyday':
period => daily,
range => "2-4"
}
exec { "/usr/bin/apt-get update":
schedule => 'everyday'
}
You can declare the schedule resource anywhere in your manifests, as long
as it ends up in the final compiled catalog. See the schedule type for more information.
stage
- Declare the new stage as a
stage
resource See the stage type for details. - Declare an order relationship between the new stage and the
main
stage. - Use the resource-like syntax to declare the class, and set the
stage
metaparameter to the name of the desired stage.
include
.
By default, all classes are declared in the main
stage.stage { 'pre':
before => Stage['main'],
}
class { 'apt-updates':
stage => 'pre',
}
subscribe
Specifies one or more resources that depend on this resource, expressed as resource references. Specify multiple resources as an array of references.
When this attribute is present, the subscribed resources are applied before this resource. If Puppet makes changes to any of the subscribed resources, it causes this resource to refresh. Refresh behavior varies by resource type: for example, services restart and mounts unmount and re-mount. Not all types can refresh.
This is one of the four relationship metaparameters, along with before
, require
, and
notify
. For more information about creating
relationships between resources, see Relationships and ordering. For
details about resource references, see Resource and class references.
tag
file {'/etc/hosts':
ensure => file,
source => 'puppet:///modules/site/hosts',
mode => '0644',
tag => ['bootstrap', 'minimumrun', 'mediumrun'],
}
Tags are useful for things like applying a subset of a host's configuration with the
tags
configuration setting, such as with puppet agent --test --tags bootstrap
. See the
configuration reference for more information about the tags setting