☛ September 7, 2013 ❝The Puppet Show — Quick bonding of resources❞
Categorized devops ≀ Tagged how.to puppet
To avoid modelling simple dependencies between resources using the somewhat tedious and chatty require and notify attributes,
the ->
and ~>
operators can help.
They are applicable to any resources that are by nature closely related and thus defined in the same file anyway.
A typical example is a group and a user belonging to it:
class accounts::admins {
group { 'admin': ensure => 'present' }
->
user { 'sysop':
ensure => 'present',
comment => 'now coming with sudo power!',
gid => 'users',
groups => ['admin',],
}
}
You can chain more users belonging to the same group by appending another … -> user {…}
construct.
For update notification relationships, ~>
does the same thing.