Alternative Augeas-based providers for Puppet
Browse collection: herculesteam
Examples are given below for each of the providers and custom types in
augeasproviders
.
This is a custom type and provider supplied by augeasproviders
.
apache_directive { "StartServers":
args => 4,
ensure => present,
}
apache_directive { "ServerName":
args => "foo.example.com",
ensure => absent,
}
apache_directive { "SetEnv":
args => ["SPECIAL_PATH", "/foo/bin"],
args_params => 1,
ensure => present,
target => "/etc/httpd/conf.d/app.conf",
}
The SetEnv
directive is not unique per scope: the first arg identifies the entry we want to update, and needs to be taken into account. For this reason, we set args_params
to 1
.
apache_directive { 'StartServers for mpm_prefork_module':
ensure => present,
name => 'StartServers',
context => 'IfModule[arg="mpm_prefork_module"]',
args => 4,
}
The directive is nested in the context of the mpm_prefork_module
module, so we specify this with the context
parameter.
The value of StartServers
for the mpm_prefork_module
module will be set/updated to 4
. Note that the IfModule
entry will not be created if it is missing.
This is a custom type and provider supplied by augeasproviders
.
apache_setenv { "SPECIAL_PATH":
ensure => present,
value => "/foo/bin",
}
apache_setenv { "ENABLE_FOO":
ensure => present,
}
apache_setenv { "SPECIAL_PATH":
ensure => absent,
}
apache_setenv { "SPECIAL_PATH":
ensure => present,
value => "/foo/bin",
target => "/etc/httpd/conf.d/app.conf",
}
This is a provider for a type distributed in Puppet core: host type reference.
The provider needs to be explicitly given as augeas
to use augeasproviders
.
The comment
parameter is only supported on Puppet 2.7 and higher.
host { "example":
ensure => present,
ip => "192.168.1.1",
provider => augeas,
}
host { "example":
ensure => present,
ip => "192.168.1.1",
host_aliases => [ "foo-a", "foo-b" ],
comment => "test",
provider => augeas,
}
host { "example":
ensure => present,
ip => "192.168.1.1",
target => "/etc/anotherhosts",
provider => augeas,
}
host { "iridium":
ensure => absent,
provider => augeas,
}
host { "iridium":
ensure => present,
host_aliases => [],
provider => augeas,
}
host { "argon":
ensure => present,
comment => "",
provider => augeas,
}
This is a custom type and provider supplied by augeasproviders
. It supports
both GRUB Legacy (0.9x) and GRUB 2 configurations.
kernel_parameter { "quiet":
ensure => present,
}
kernel_parameter { "elevator":
ensure => present,
value => "deadline",
}
kernel_parameter { "rd_LVM_LV":
ensure => present,
value => ["vg/lvroot", "vg/lvvar"],
}
Bootmode defaults to “all”, so settings are applied for all boot types usually.
Apply only to normal boots:
kernel_parameter { "quiet":
ensure => present,
bootmode => "normal",
}
Only recovery mode boots (unsupported with GRUB 2):
kernel_parameter { "quiet":
ensure => present,
bootmode => "recovery",
}
kernel_parameter { "rhgb":
ensure => absent,
}
kernel_parameter { "elevator":
ensure => present,
value => "deadline",
target => "/mnt/boot/grub/menu.lst",
}
This is a provider for a type distributed in Puppet core: mailalias type reference.
The provider needs to be explicitly given as augeas
to use augeasproviders
.
mailalias { "example":
ensure => present,
recipient => "bar",
provider => augeas,
}
mailalias { "example":
ensure => present,
recipient => [ "fred", "bob" ],
provider => augeas,
}
mailalias { "example":
ensure => present,
recipient => "bar",
target => "/etc/anotheraliases",
provider => augeas,
}
mailalias { "mailer-daemon":
ensure => absent,
provider => augeas,
}
This is a provider for a type distributed in the puppetlabs-mount_providers module.
The provider needs to be explicitly given as augeas
to use augeasproviders
.
If editing a vfstab entry, slightly different options need to be passed compared to a fstab entry.
mounttab { "/mnt":
ensure => present,
device => "/dev/myvg/mytest",
fstype => "ext4",
options => "defaults",
provider => augeas,
}
mounttab { "/mnt":
ensure => present,
device => "/dev/myvg/mytest",
fstype => "ext4",
options => ["nosuid", "uid=12345"],
dump => "1",
pass => "2",
provider => augeas,
}
mounttab { "/mnt":
ensure => present,
device => "/dev/myvg/mytest",
fstype => "ext4",
provider => augeas,
}
mounttab { "/":
ensure => absent,
provider => augeas,
}
mounttab { "/home":
ensure => present,
device => "/dev/myvg/mytest",
target => "/etc/anotherfstab",
provider => augeas
}
mounttab { "/home":
ensure => present,
device => "/dev/myvg/mytest",
provider => augeas
}
Note: dump and pass are both changing unless explicitly specified, see issue #16122.
mounttab { "/home":
ensure => present,
fstype => "btrfs",
provider => augeas,
}
mounttab { "/home":
ensure => present,
options => "nosuid",
provider => augeas,
}
mounttab { "/home":
ensure => present,
options => [
"nosuid",
"uid=12345",
'rootcontext="system_u:object_r:tmpfs_t:s0"',
],
provider => augeas,
}
mounttab { "/home":
ensure => present,
options => [],
provider => augeas,
}
mounttab { "/mnt":
ensure => present,
device => "/dev/dsk/c1t1d1s1",
fstype => "ufs",
atboot => "yes",
provider => augeas,
}
mounttab { "/mnt":
ensure => present,
device => "/dev/dsk/c1t1d1s1",
blockdevice => "/dev/foo/c1t1d1s1",
fstype => "ufs",
pass => "2",
atboot => "yes",
options => [ "nosuid", "nodev" ],
provider => augeas,
}
mounttab { "/mnt":
ensure => present,
device => "/dev/myvg/mytest",
fstype => "ext4",
provider => augeas,
}
mounttab { "/":
ensure => absent,
provider => augeas,
}
mounttab { "/home":
ensure => present,
options => [],
provider => augeas,
}
This is a custom type and provider supplied by augeasproviders
.
nrpe_command { "check_spec_test":
ensure => present,
command => "/usr/bin/check_my_thing -p 'some command with \"multiple [types]\" of quotes' -x and-stuff",
}
nrpe_command { "check_test":
ensure => absent,
}
This is a custom type and provider supplied by augeasproviders
.
pam { "Set sss entry to system-auth auth":
ensure => present,
service => 'system-auth',
type => 'auth',
control => 'sufficient',
module => 'pam_sss.so',
arguments => 'use_first_pass',
position => 'before module pam_deny.so',
}
pam { "Set sss entry to system-auth auth":
ensure => present,
service => 'system-auth',
type => 'auth',
control => 'sufficient',
module => 'pam_sss.so',
arguments => 'use_first_pass',
position => 'before *[type="auth" and module="pam_deny.so"]',
}
pam { "Remove sss auth entry from system-auth":
ensure => absent,
service => 'system-auth',
type => 'auth',
module => 'pam_sss.so',
}
pam { "Remove all pam_sss.so from system-auth":
ensure => absent,
service => 'system-auth',
module => 'pam_sss.so',
}
pam { "Set cracklib limits in password-auth":
ensure => present,
service => 'password-auth',
type => 'password',
module => 'pam_cracklib.so',
arguments => ['try_first_pass','retry=3', 'minlen=10'],
}
pam { "Set cracklib limits in password-auth":
ensure => present,
service => 'password-auth',
type => 'password',
module => 'pam_cracklib.so',
arguments => ['try_first_pass','retry=3', 'minlen=10'],
target => '/etc/pam.conf',
}
pam { "Set invalid login 3 times deny in password-auth -fail":
ensure => present,
service => 'password-auth',
type => 'auth',
control => '[default=die]',
control_is_param => true,
module => 'pam_faillock.so',
arguments => ['authfail','deny=3','unlock_time=604800','fail_interval=900'],
}
This is a custom type and provider supplied by augeasproviders
.
This type supports composite namevars in order to easily specify the entry you want to manage. The format for composite namevars is:
local to <user> on <database> [in <target>]
if defining a local (socket) rule, or:
<type> to <user> on <database> from <address> [in <target>]
otherwise.
In each form, in <target>
is optional. You can also use a personalized namevar and specify all parameters manually.
pg_hba { 'local to all on all':
ensure => present,
method => 'md5',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'host to all on all from 192.168.0.1':
ensure => present,
method => 'md5',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'host to user1,user2 on db1,db2 from 192.168.0.1':
ensure => present,
method => 'md5',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'Allow +foo and @bar to mydb and yourdb':
ensure => present,
user => ['+foo', '@bar'],
database => ['mydb', 'yourdb'],
method => 'md5',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'Default entry':
type => 'local',
user => 'all',
database => 'all',
method => 'md5',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'Default entry with option':
method => 'ident',
options => { 'sameuser' => undef },
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'host to all on all from .dev.example.com in /etc/postgresql/9.1/main/pg_hba.conf':
method => 'ldap',
options => {
'ldapserver' => 'auth.example.com',
'ldaptls' => '1',
'ldapprefix' => 'uid=',
'ldapsuffix' => ',ou=people,dc=example,dc=com',
},
}
pg_hba { 'local to all on all':
ensure => present,
method => 'md5',
position => 'before first entry',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'local to all on all':
ensure => present,
method => 'md5',
position => 'after last entry',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'local to all on all':
ensure => present,
method => 'md5',
position => 'before last local',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'local to all on all':
ensure => present,
method => 'md5',
position => 'after first hostssl',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'local to all on all':
ensure => present,
method => 'md5',
position => 'after first anyhost', # any type matching host.*
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'local to all on all':
ensure => present,
method => 'md5',
position => 'before 5', # Before the fifth entry
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'local to all on all':
ensure => present,
method => 'md5',
position => '*[database="all" and user="admin"][1]', # First entry for database 'all' and user 'admin'
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'local to all on all':
ensure => positioned,
method => 'md5',
position => 'before first entry',
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'local to all on all':
ensure => absent,
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
pg_hba { 'host to all on all from 192.168.0.1':
ensure => absent,
target => '/etc/postgresql/9.1/main/pg_hba.conf',
}
This is a custom type and provider supplied by augeasproviders
.
It requires the Puppet_Auth.lns
lens, which is provided with versions of Augeas strictly greater than 0.10.0.
puppet_auth { 'Deny /facts':
ensure => present,
path => '/facts',
authenticated => 'any',
}
puppet_auth { 'Deny ~ ^/facts/([^/]+)$':
ensure => present,
path => '^/facts/([^/]+)$',
path_regex => true,
authenticated => 'any',
}
puppet_auth { 'Allow /facts for prod and dev environments from same client':
ensure => present,
path => '/facts',
authenticated => 'any',
allow => '$1',
environments => ['prod', 'dev'],
}
ins_after
provides the opposite functionality, so an entry is created after a
given path.
puppet_auth { 'Allow /facts before first denied rule':
ensure => present,
path => '/facts',
authenticated => 'any',
allow => '*',
ins_before => 'first deny',
}
puppet_auth { 'Remove /facts':
ensure => absent,
path => '/facts',
}
This is a custom type and provider supplied by augeasproviders
.
shellvar { "HOSTNAME":
ensure => present,
target => "/etc/sysconfig/network",
value => "host.example.com",
}
shellvar { "disable rsyncd":
ensure => present,
target => "/etc/default/rsync",
variable => "RSYNC_ENABLE",
value => "false",
}
shellvar { "ntpd options":
ensure => present,
target => "/etc/sysconfig/ntpd",
variable => "OPTIONS",
value => "-g -x -c /etc/myntp.conf",
}
shellvar { "HOSTNAME":
ensure => present,
target => "/etc/sysconfig/network",
comment => "My server's hostname",
value => "host.example.com",
}
shellvar { "HOSTNAME":
ensure => exported,
target => "/etc/sysconfig/network",
value => "host.example.com",
}
shellvar { "HOSTNAME":
ensure => unset,
target => "/etc/sysconfig/network",
}
Values needing quotes will automatically get them, but they can also be explicitly enabled. Unfortunately the provider doesn’t help with quoting the values themselves.
shellvar { "RSYNC_IONICE":
ensure => present,
target => "/etc/default/rsync",
value => "-c3",
quoted => "single",
}
shellvar { "RSYNC_IONICE":
ensure => absent,
target => "/etc/default/rsync",
}
shellvar { "HOSTNAME":
ensure => present,
target => "/etc/sysconfig/network",
comment => "",
}
shellvar { "HOSTNAME":
ensure => present,
target => "/etc/sysconfig/network",
comment => "",
uncomment => true,
}
You can pass array values to the type.
There are two ways of rendering array values, and the behavior is set using
the array_type
parameter. array_type
takes three possible values:
auto
(default): detects the type of the existing variable, defaults to string
;string
: renders the array as a string, with a space as element separator;array
: renders the array as a shell array.For example:
shellvar { "PORTS":
ensure => present,
target => "/etc/default/puppetmaster",
value => ["18140", "18141", "18142"],
array_type => "auto",
}
will create PORTS="18140 18141 18142"
by default, and will change PORTS=(123)
to PORTS=("18140" "18141" "18142")
.
shellvar { "PORTS":
ensure => present,
target => "/etc/default/puppetmaster",
value => ["18140", "18141", "18142"],
array_type => "string",
}
will create PORTS="18140 18141 18142"
by default, and will change PORTS=(123)
to PORTS="18140 18141 18142"
.
shellvar { "PORTS":
ensure => present,
target => "/etc/default/puppetmaster",
value => ["18140", "18141", "18142"],
array_type => "array",
}
will create PORTS=("18140" "18141" "18142")
by default, and will change PORTS=123
to PORTS=(18140 18141 18142)
.
Quoting is honored for arrays:
shellvar { "GRUB_CMDLINE_LINUX":
ensure => present,
target => "/etc/default/grub",
value => "cgroup_enable=memory",
array_append => true,
}
will change GRUB_CMDLINE_LINUX="quiet splash"
to GRUB_CMDLINE_LINUX="quiet splash cgroup_enable=memory"
.
shellvar { "GRUB_CMDLINE_LINUX":
ensure => present,
target => "/etc/default/grub",
value => ["quiet", "cgroup_enable=memory"],
array_append => true,
}
will also change GRUB_CMDLINE_LINUX="quiet splash"
to GRUB_CMDLINE_LINUX="quiet splash cgroup_enable=memory"
.
This is a custom type and provider supplied by augeasproviders
.
ssh_config { "ForwardAgent":
ensure => present,
value => "yes",
}
ssh_config { "SendEnv":
ensure => present,
value => ["LC_*", "LANG"],
}
ssh_config { "X11Forwarding":
ensure => present,
host => "example.net",
value => "yes",
}
ssh_config { "ForwardAgent global":
ensure => present,
key => "ForwardAgent",
value => "no",
}
ssh_config { "ForwardAgent on example.net":
ensure => present,
key => "ForwardAgent",
host => "example.net",
value => "yes",
}
ssh_config { "HashKnownHosts":
ensure => absent,
}
ssh_config { "BatchMode":
ensure => absent,
host => "example.net",
}
ssh_config { "CheckHostIP":
ensure => present,
value => "yes",
target => "/etc/ssh/another_sshd_config",
}
This is a custom type and provider supplied by augeasproviders
.
sshd_config { "PermitRootLogin":
ensure => present,
value => "yes",
}
sshd_config { "AllowGroups":
ensure => present,
value => ["sshgroups", "admins"],
}
sshd_config { "X11Forwarding":
ensure => present,
condition => "Host foo User root",
value => "yes",
}
sshd_config { "AllowAgentForwarding":
ensure => present,
condition => "Host *.example.net",
value => "yes",
}
sshd_config { "X11Forwarding global":
ensure => present,
key => "X11Forwarding",
value => "no",
}
sshd_config { "X11Forwarding foo":
ensure => present,
key => "X11Forwarding",
condition => "User foo",
value => "yes",
}
sshd_config { "X11Forwarding root":
ensure => present,
key => "X11Forwarding",
condition => "User root",
value => "no",
}
sshd_config { "PermitRootLogin":
ensure => absent,
}
sshd_config { "AllowAgentForwarding":
ensure => absent,
condition => "Host *.example.net User *",
}
sshd_config { "PermitRootLogin":
ensure => present,
value => "yes",
target => "/etc/ssh/another_sshd_config",
}
This is a custom type and provider supplied by augeasproviders
.
sshd_config_subsystem { "sftp":
ensure => present,
command => "/usr/lib/openssh/sftp-server",
}
sshd_config_subsystem { "sftp":
ensure => absent,
}
sshd_config_subsystem { "sftp":
ensure => present,
command => "/usr/lib/openssh/sftp-server",
target => "/etc/ssh/another_sshd_config",
}
sshkey { "foo.example.com":
ensure => present,
type => "ssh-rsa",
key => "AAADEADMEAT",
}
sshkey { "foo.example.com":
ensure => present,
type => "ssh-rsa",
key => "AAADEADMEAT",
host_aliases => [ 'foo', '192.168.0.1' ],
}
sshkey { "foo.example.com":
ensure => present,
type => "ssh-rsa",
key => "AAADEADMEAT",
hash_hostname => true,
}
sshkey { "foo.example.com":
ensure => hashed,
type => "ssh-rsa",
key => "AAADEADMEAT",
hash_hostname => true,
}
sshkey { "foo.example.com":
ensure => absent,
}
sshkey { "foo.example.com":
ensure => present,
type => "ssh-rsa",
key => "AAADEADMEAT",
target => "/root/.ssh/known_hosts",
}
This is a custom type and provider supplied by augeasproviders
.
sysctl { "net.ipv4.ip_forward":
ensure => present,
value => "1",
}
sysctl { "net.ipv4.ip_forward":
ensure => present,
value => "1",
comment => "test",
}
sysctl { "kernel.sysrq":
ensure => absent,
}
sysctl { "kernel.sysrq":
ensure => present,
comment => "",
}
sysctl { "net.ipv4.ip_forward":
ensure => present,
value => "1",
target => "/etc/sysctl.d/forwarding.conf",
}
sysctl
commandsysctl { "net.ipv4.ip_forward":
ensure => present,
value => "1",
apply => false,
}
This is a custom type, with two providers supplied by augeasproviders
. A
syslog
provider handles basic syslog configs, while an rsyslog
provider
handles the extended rsyslog config (this requires Augeas 1.0.0).
syslog { "my test":
ensure => present,
facility => "local2",
level => "*",
action_type => "file",
action => "/var/log/test.log",
}
syslog { "cron.*":
ensure => present,
facility => "cron",
level => "*",
action_type => "file",
action => "/var/log/cron",
no_sync => true,
}
syslog { "my test":
ensure => present,
facility => "local2",
level => "*",
action_type => "hostname",
action => "centralserver",
}
syslog { "my test":
ensure => present,
facility => "local2",
level => "*",
action_type => "hostname",
action_port => "514",
action_protocol => "tcp",
action => "centralserver",
}
syslog { "my test":
ensure => present,
facility => "local2",
level => "*",
action_type => "user",
action => "root",
}
syslog { "my test":
ensure => present,
facility => "local2",
level => "*",
action_type => "program",
action => "/usr/bin/foo",
}
syslog { "mail.*":
ensure => absent,
facility => "mail",
level => "*",
action_type => "file",
action => "/var/log/maillog",
}
syslog { "my test":
ensure => present,
facility => "local2",
level => "*",
action_type => "file",
action => "/var/log/test.log",
provider => "rsyslog",
}
syslog { "my test":
ensure => present,
facility => "local2",
level => "*",
action_type => "file",
action => "/var/log/test.log",
target => "/etc/mysyslog.conf",
}