Specifying file paths
Options for specifying a file path.
| Key | Data type | Expected value |
|---|---|---|
path
|
String | One file path. |
paths
|
Array | Any number of file paths. This acts like a sub-hierarchy: if multiple files exist, Hiera searches all of them, in the order in which they're written. |
glob
|
String | One shell-like glob pattern, which might match any number of files. If multiple files are found, Hiera searches all of them in alphanumerical order. |
globs
|
Array | Any number of shell-like glob patterns. If multiple files are found, Hiera searches all of them in alphanumerical order (ignoring the order of the globs). |
mapped_paths
|
Array or Hash | A fact that is a collection (array or hash) of values. Hiera expands these values to produce an array of paths. |
Explicit file extensions are required, for example, common.yaml, not common.
File paths are relative to the datadir: if the full datadir is /etc/puppetlabs/code/environments/production/data and the file path is set
to "nodes/%{trusted.certname}.yaml",
the full path to the file is /etc/puppetlabs/code/environments/production/data/nodes/<NODE
NAME>.yaml.
Globs are implemented with Ruby's
Dir.glob method:
- One asterisk (
*) matches a run of characters. - Two asterisks (
**) matches any depth of nested directories. - A question mark (
?) matches one character. - Comma-separated lists in curly braces (
{one,two}) match any option in the list. - Sets of characters in square brackets (
[abcd]) match any character in the set. - A backslash (
\) escapes special characters.
Example:
- name: "Domain or network segment"
glob: "network/**/{%{facts.networking.domain},%{facts.networking.interfaces.en0.bindings.0.network}}.yaml"
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 is 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"]. The following configuration has the same results as if paths had
been specified to be [service/a/common.yaml,
service/b/common.yaml, service/c/common.yaml].
- name: Example
mapped_paths: [services, tmp, "service/%{tmp}/common.yaml"]
Related information