I've got a custom fact that spits out a list of server types (web, app, db, etc). I'd like to do classification on this fact, but when I try using one of the server types in my hiera config, it doesn't work.
For simplicity, I've tested with another fact (filesystems) that also returns multiple values.
# 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?
Paul