How to create resources from a config file.
Hi, I'm fairly new to puppet and come from a programming background, so please forgive me if I'm just thinking about this wrong.
What I would like to achieve is having a single, simple, editable file that contains information about vendors and their employees. Nothing fancy, just the vendor name and a login name for the employee. Then I want puppet to create the home folder structure which incorporates the vendor name with the username. There is also a shared area per vendor that all users for that vendor have access.
I have a puppet class that will create a group and a single vendor structure (forget the users for now)...
root@puppettest01:/etc/puppet/modules/vendor-setup/manifests# cat vendor.pp
class vendor (
$vendor_name = 'Unh'
) {
group { $vendor_name:
ensure => present,
}
file { "/home/":
ensure => directory,
mode => 0751,
owner => 'root',
group => 'root',
}
file { "/home/${vendor_name}/":
ensure => directory,
mode => 0750,
owner => 'root',
group => $vendor_name,
}
file { "/home/${vendor_name}/shared/":
ensure => directory,
mode => 0770,
owner => 'root',
group => $vendor_name,
}
}
But I haven't been able to get it to make more than one in a single pass. I've seen example of creating multiple resources from one class, but they all seem to rely on either pre-defining all the variables for each instantiation, or don't need to use a variable in the setup part, just the name of the file or directory or whatever.
I tried parametrizing the class, but that still seemed to limit me to one final class to be evaluated. I looked at create_resources which looked promising, but required me to create my own custom resource type, and I can't help but feel it should be simpler than that.
Hiera data also seemed promising, but I still haven't figured out the link to make multiple resources based on my class, that are also aware of the variable I want to pass to them without having to define everything for each instance.
Any help or pointers greatly appreciated. :)
EDIT:
Some clarification. The above class works fine to create a single structure with a supplied vendor name. What I want to do is have something like a yaml file with, say...
---
:Vendor1:
- Fred
- Bob
:Vendor2:
- Kate
- Alex
And so on. Puppet would then use each vendor definition to create the appropriate structure as mapped out above, ensure the group exists and use it to apply security to the created folders.
It's the step between making a single instance and making multiple instances that will accept my vendor name as a variable that I seem to be missing.
Cheers, grist.