That looks great, thanks! However, I just realized that my server roles are somewhat related to the server names. For example, I could call my webservers something like www1, www2, www3. If all those 3 servers have the same config, is there a way to create a file that would apply to all of them? Something like /hiera/hosts/www?.yaml ?
If not, could I use a hard or soft link? Thanks, On Thursday, October 27, 2016 at 3:52:49 AM UTC-4, Thomas Müller wrote: > > > > Am Dienstag, 18. Oktober 2016 20:34:25 UTC+2 schrieb Ugo Bellavance: >> >> Hi, >> >> I've seen tutorials where they add the role as a fact in an client and >> then can use the role for hiera data. Is there a better way to do so (ie >> without having to configure anything on the client)? >> > > you could add a hiera call to your main site.pp* to define a top-scope > variable which then is also usable in the hiera hiearchy. > > $role = hiera('role', 'default') > > node "default" { > include "::role::${::role}" > # or hiera_include* > hiera_include() > } > > > hiera.yaml example: > > > :backends: > - yaml > :yaml: > :datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata" > :hierarchy: > - "nodes/%{::trusted.certname}" > - "virtual/%{::role}" > - "osfamily/%{::osfamily}" > - common > > > there are more pretty solutions like > https://github.com/ripienaar/puppet-classifier on Puppet4 and with the > new lookup() functions with supports "knockout". > > - Thomas > > > * https://docs.puppet.com/puppet/latest/reference/dirs_manifest.html > > > https://docs.puppet.com/hiera/3.2/puppet.html#assigning-classes-to-nodes-with-hiera-hierainclude > > https://docs.puppet.com/hiera/3.2/complete_example.html > > https://www.devco.net/archives/2016/03/13/the-puppet-4-lookup-function.php > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/8413155f-08f8-4437-b018-58353e57af4e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.