Skip to content

Commit 858b68b

Browse files
author
Kevin Paulisse
committed
Add additional documentation and simplify hiera config even more
1 parent 1afcbd7 commit 858b68b

2 files changed

Lines changed: 44 additions & 38 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Configuring octocatalog-diff to use Hiera path stripping
2+
3+
This is a different, and potentially more complex, alternative to `hiera-path` / `settings[:hiera_path]` described in the [Configuring octocatalog-diff to use Hiera](/doc/configuration-hiera.md) document. Unless you have a very good reason, you should prefer to use the instructions in that document instead of using the more complicated option that is described herein.
4+
5+
The command line option `--hiera-path-strip PATH` allows you to manipulate directory paths for the JSON or YAML hiera backends. This setting only has an effect on the copy of hiera.yaml that is copied into the temporary compilation directory. This does not make any changes to the actual source hiera.yaml file on your system or in your checkout.
6+
7+
For example, perhaps your production hiera.yaml file has entries such as the following:
8+
9+
```
10+
---
11+
:backends:
12+
- yaml
13+
:hierarchy:
14+
- "nodes/%{::trusted.certname}"
15+
- common
16+
17+
:yaml:
18+
:datadir: /etc/puppetlabs/code/environments/%{environment}/hieradata
19+
```
20+
21+
However, when you run octocatalog-diff on a machine that is not a Puppet master, the hiera data will not actually be found in `/etc/puppetlabs/code/environments/production/hieradata`, but rather in a directory called `hiera` relative to the checkout of your Puppet code.
22+
23+
Specifying `--hiera-path-strip PATH` causes octocatalog-diff to munge the datadir for the YAML and JSON configuration. The correct command in this case is now:
24+
25+
```
26+
bin/octocatalog-diff --hiera-config hiera.yaml --hiera-path-strip /etc/puppetlabs/code
27+
```
28+
29+
```
30+
---
31+
:backends:
32+
- yaml
33+
:hierarchy:
34+
- "nodes/%{::trusted.certname}"
35+
- common
36+
37+
:yaml:
38+
:datadir: /var/tmp/puppet-compile-dir-92347829847/environments/%{environment}/hieradata
39+
```

doc/configuration-hiera.md

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ You may specify this as either an absolute or a relative path.
2424
bin/octocatalog-diff --hiera-config hiera.yaml ...
2525
```
2626
27-
The path is relative to a checkout of your Puppet repository. As per the example in the introduction, say that octocatalog-diff is using a temporary directory of `/var/tmp/puppet-compile-dir-92347829847` when compiling a Puppet catalog. With the setting above, it will use the file named `hiera.yaml` that is at the top level
27+
The path is relative to a checkout of your Puppet repository. With the setting above, it will use the file named `hiera.yaml` that is at the top level
2828
of your Puppet checkout.
2929
3030
Perhaps your hiera.yaml file is in a subdirectory of your Puppet checkout. In that case, just use the relative directory path. Be sure not to add a leading `/` though,
@@ -39,6 +39,7 @@ You may specify this as either an absolute or a relative path.
3939
4040
```
4141
settings[:hiera_config] = 'hiera.yaml'
42+
(or)
4243
settings[:hiera_config] = 'config/hiera.yaml'
4344
```
4445
@@ -76,7 +77,7 @@ You must specify this as a relative path. octocatalog-diff knows to use a relati
7677
bin/octocatalog-diff --hiera-path hieradata ...
7778
```
7879
79-
The path is relative to a checkout of your Puppet repository. As per the example in the introduction, say that octocatalog-diff is using a temporary directory of `/var/tmp/puppet-compile-dir-92347829847` when compiling a Puppet catalog. With the setting above, it will look for Hiera data in a directory called `hieradata` that is at the top level
80+
The path is relative to a checkout of your Puppet repository. With the setting above, it will look for Hiera data in a directory called `hieradata` that is at the top level
8081
of your Puppet checkout.
8182
8283
If you are specifying the Hiera data path in the [configuration file](/doc/configuration.md), you will instead set the variable like this:
@@ -89,40 +90,6 @@ octocatalog-diff will fail if you specify a path that is not a directory.
8990
9091
## Configuring the prefix path to strip
9192
92-
This is a different, and potentially more complex, alternative to `hiera-path` / `settings[:hiera_path]` described in the prior section. Unless you have a very good reason, you should prefer to use the instructions in the previous sections instead of doing the following.
93+
This is a different, and potentially more complex, alternative to `hiera-path` / `settings[:hiera_path]` described in the prior section. Unless you have a very good reason, you should prefer to use the instructions above.
9394
94-
The command line option `--hiera-path-strip PATH` allows you to manipulate directory paths for the JSON or YAML hiera backends. This setting only has an effect on the copy of hiera.yaml that is copied into the temporary compilation directory. This does not make any changes to the actual source hiera.yaml file on your system or in your checkout.
95-
96-
For example, perhaps your production hiera.yaml file has entries such as the following:
97-
98-
```
99-
---
100-
:backends:
101-
- yaml
102-
:hierarchy:
103-
- "nodes/%{::trusted.certname}"
104-
- common
105-
106-
:yaml:
107-
:datadir: /etc/puppetlabs/code/environments/%{environment}/hieradata
108-
```
109-
110-
However, when you run octocatalog-diff on a machine that is not a Puppet master, the hiera data will not actually be found in `/etc/puppetlabs/code/environments/production/hieradata`, but rather in a directory called `hiera` relative to the checkout of your Puppet code.
111-
112-
Specifying `--hiera-path-strip PATH` causes octocatalog-diff will munge the datadir for the YAML and JSON configuration. The correct command in this case is now:
113-
114-
```
115-
bin/octocatalog-diff --hiera-config hiera.yaml --hiera-path-strip /etc/puppetlabs/code
116-
```
117-
118-
```
119-
---
120-
:backends:
121-
- yaml
122-
:hierarchy:
123-
- "nodes/%{::trusted.certname}"
124-
- common
125-
126-
:yaml:
127-
:datadir: /var/tmp/puppet-compile-dir-92347829847/environments/%{environment}/hieradata
128-
```
95+
If you need to use the prefix path strip option, see: [Configuring octocatalog-diff to use Hiera path stripping](/doc/advanced-hiera-path-stripping.md).

0 commit comments

Comments
 (0)