On Thursday, December 12, 2013 7:33:26 AM UTC+9, Paul Archer wrote:
>
> *# this is a typical facter output for filesystems*
> root@puppetmaster:/etc/puppet/hieradata# facter filesystems
> ext4,iso9660
>
> *# my hiera.yaml, to show the first entry in my hierarchy is for the 
> filesystems fact*
> root@puppetmaster:/etc/puppet/hieradata# cat /etc/hiera.yaml
> ---
> :backends:
>   - yaml
>
> :hierarchy:
>     - "%{filesystems}"
>     - global
>     - "nodes/%{clientcert}"
>     - "groups/%{server_groups}"
>     - "environment_%{environment}"
>     - "os/%{osfamily}"
>     - "os/%{osfamily}/%{operatingsystemmajrelease}"
>     - "virtual_%{::virtual}"
>     - defaults
>     - credentials
>
> :yaml:
>   :datadir: /etc/puppet/hieradata
>
>
> *# my yaml file has a an entry for motd::banner (my 'play with' data)*
> root@puppetmaster:/etc/puppet/hieradata# cat 
> /etc/puppet/hieradata/ext4.yaml 
> ---
>
> motd::banner: this is for the ext4 filesystem
>
>
> *# without any facts, I get the default*
> root@puppetmaster:/etc/puppet/hieradata# hiera motd::banner
> Hi there! This system is managed by puppet. (defaults.yaml)
>
>
> *# with the filesystem fact set to ext4, I get the right value*
> root@puppetmaster:/etc/puppet/hieradata# hiera motd::banner 
> filesystems=ext4
> this is for the ext4 filesystem
>
> *# with the filesystem fact set to exactly what I get from facter, I'm 
> back to the default*
> root@puppetmaster:/etc/puppet/hieradata# hiera motd::banner 
> filesystems=ext4,iso9660
> Hi there! This system is managed by puppet. (defaults.yaml)
>
>
> Is it possible to use a fact that contains multiple values within hiera? 
> If so, what am I missing? If not, what's the point of having facts with 
> multiple values in the first place?
>


Facter was designed before hiera. It serves a larger purpose than just 
usage as hiera hierarchy conditionals.

Do I understand correctly that your custom fact which "spits out a list of 
server types" returns more than 1 item in a comma separated list like the 
filesystems example you provided?

Looking at the nature of this custom fact would it not be better if it 
provided a single 'server type'? If this is impossible, you could split the 
fact into X facts and (servertype1,servertype2 and servertype3) which could 
then be used nicely in hiera.

If your custom fact is outputting a highly variable string (that looks like 
multiple values due to a comma), then it's not really suitable to use in 
hiera.yaml I believe.


-- 
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/193db15f-c47b-4838-a2de-03b98d7395d1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to