Other built-in types

Beyond package, file, and service, these core types are among the most useful and commonly used.

 

notify

Logs an arbitrary message, at the notice log level. This appears in the POSIX syslog or Windows Event Log on the agent node and is also logged in reports.

notify { "This message is getting logged on the agent node.": }
AttributeDescriptionNotes
messageThe message to log.Defaults to title.

exec

Executes an arbitrary command on the agent node. When using execs, you must either make sure the command can be safely run multiple times, or specify that it runs only under certain conditions.

Important attributes Description Notes
command The command to run. If this isn’t a fully-qualified path, use the path attribute. Defaults to title.
path Where to look for executables, as a colon-separated list or an array.  
returns Which exit codes indicate success. Defaults to 0.
environment An array of environment variables to set (for example, ['MYVAR=somevalue', 'OTHERVAR=othervalue']).  
The following attributes limit when a command runs.
creates A file to look for before running the command. The command only runs if the file doesn’t exist.  
refreshonly If true, the command runs only if a resource it subscribes to (or a resource which notifies it) has changed.  
onlyif A command or array of commands; if any have a non-zero return value, the command won’t run.  
unless The opposite of onlyif.  
Other notable attributes: cwd, group, logoutput, timeout, tries, try_sleep, user

user

Manages user accounts; mostly used for system users.

user { "jane":
    ensure     => present,
    uid        => '507',
    gid        => 'admin',
    shell      => '/bin/zsh',
    home       => '/home/jane',
    managehome => true,
}
Important AttributesDescriptionNotes
nameThe name of the user.Defaults to title.
ensureWhether the user should exist. Allowed values:
  • present

  • absent

  • role

uidThe user ID. Must be specified numerically; chosen automatically if omitted. Read-only on Windows.
gidThe user’s primary group. Can be specified numerically or by name. Not used on Windows; use groups instead.
groupsAn array of other groups to which the user belongs.Don’t include the group specified as the gid.
homeThe user’s home directory. 
managehomeWhether to manage the home directory when managing the user. If you don’t set this to true, you’ll need to create the user’s home directory manually.
shellThe user’s login shell. 
Other notable attributes: comment, expiry, membership, password, password_max_age, password_min_age, purge_ssh_keys, salt

group

Manages groups.

Important attributes Description Notes
name The name of the group. Defaults to title.
ensure Whether the group should exist. Allowed values:
  • present

  • absent

gid The group ID; must be specified numerically, and is chosen automatically if omitted. Read-only on Windows.
members Users and groups that are members of the group. Only applicable to certain operating systems; see the full type reference for details.