Hi,
I'm trying to setup a generic hierarchy based on Hiera 5 under the following assumptions:
* a fact `roles` holds a comma-separated list of roles to use in hiera. Example: `[ 'role1', 'role2' ].join(',')` aka `"role1,role2"`
* this `roles` fact is passed to `puppet apply` using the `FACTER_roles` environment variable (which explain why the array is not passed directly).
I'm trying now to setup the `:hierarchy`section of `hiera.conf` to handle properly `facts.roles` as an array to iterate on it using [`mapped_paths`](https://docs.puppet.com/puppet/latest/hiera_config_yaml_5.html#the-hierarchy-key).
Ideally, I would like to express this iteration as follows:
# hiera.conf --- version: 5 # below version 5 are deprecated starting puppet 4.9 ### default datadir and backend for hierarchy levels. defaults: # Used for any hierarchy level that omits these keys. datadir: hieradata # This path is relative to hiera.yaml's directory. data_hash: yaml_data # Use the built-in YAML backend. hierarchy: #______________________ - name: "Per-node data" path: "nodes/%{trusted.certname}.yaml" - name: "Role Specific data" mapped_paths: [ "%{split(facts.roles, ',')}", role, "role/%{role}.yaml" ] - name: "Common data" path: "common.yaml"Assuming the above setup, I'm expecting to see hiera "loading" the following hiera files: * `hieradata/role/role1.yaml` * `hieradata/role/role2.yaml` * `hieradata/common.yaml` However it does not work: I end with a strange message ``` ==> master: Error: Evaluation Error: Error while evaluating a Function Call, Lookup of key 'noop_mode' failed: Syntax error in string: mapped_path[0] at /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/default.pp:33:14 on node puppet-master.vagrant.dev ``` I don't see the proper way to define a call to the `split` function **within** `hiera.yaml`. Can anyone help me ? ## Appendix: `mapped_paths` > The mapped_paths key must contain three string elements, in the following order:> A scope variable that points to a collection of strings.> The variable name that will be mapped to each element of the collection.> A template where that variable can be used in interpolation expressions.> For example, a fact named $services contains the array `[“a”, “b”, “c”]`. Then this configuration: >> `mapped_paths: [services, tmp, "service/%{tmp}/common.yaml"]`>> has the same results as if paths had been specified to be `[service/a/common.yaml, service/b/common.yaml, service/c/common.yaml]`.