May 2017
Beginner
268 pages
6h 1m
English
Whereas a class lets you group together related resources, a defined resource type lets you create new kinds of resources, and declare as many instances of them as you like. A defined resource type definition looks a lot like a class (defined_resource_type.pp):
# Manage user and SSH key together
define user_with_key(
String $key_type,
String $key,
) {
user { $title:
ensure => present,
managehome => true,
}
file { "/home/${title}/.ssh":
ensure => directory,
owner => $title,
group => $title,
mode => '0700',
}
ssh_authorized_key { $title:
user => $title,
type => $key_type,
key => $key,
}
}You can see that instead of the class keyword, we use the define keyword. This tells Puppet that we are creating a defined resource type instead ...
Read now
Unlock full access