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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/7d436c9c-989e-4767-8715-25b61cfa0d85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to