Skip to content

Commit cb95f1f

Browse files
authored
Merge pull request #29 from github/kpaulisse-documentation-environment
Document environment variable passing for bootstrap and ENC
2 parents a067711 + 217070c commit cb95f1f

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

doc/advanced-bootstrap.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,28 @@ The [example configuration file](/examples/octocatalog-diff.cfg.rb) contains an
3131
# settings[:bootstrap_script] = '/etc/puppetlabs/repo-bootstrap.sh' # Absolute path
3232
# settings[:bootstrap_script] = 'script/bootstrap' # Relative path
3333
```
34+
35+
## Bootstrap environment
36+
37+
When the bootstrap script runs, a limited set of environment variables are passed from the shell running octocatalog-diff. Only these variables are set:
38+
39+
- `HOME`
40+
- `PATH`
41+
- `PWD` (set to the base directory of your Puppet checkout)
42+
- `BASEDIR` (as explicitly set with `--basedir` CLI option or `settings[:basedir]` setting)
43+
44+
If you wish to set additional environment variables for your bootstrap script, you may do so via the `--bootstrap-environment VAR=value` command line flag, or by defining `settings[:bootstrap_environment] = { 'VAR' => 'value' }` in your configuration file.
45+
46+
As an example, consider that your bootstrap script is written in Python, and needs the `PYTHONPATH` variable set to `/usr/local/lib/python-custom`. Even if this environment variable is set when octocatalog-diff is run, it will not be available to the bootstrap script. You may supply it via the command line:
47+
48+
```
49+
octocatalog-diff --bootstrap-environment PYTHONPATH=/usr/local/lib/python-custom ...
50+
```
51+
52+
Or you may specify it in your configuration file:
53+
54+
```
55+
settings[:bootstrap_environment] = {
56+
'PYTHONPATH' => '/usr/local/lib/python-custom'
57+
}
58+
```

doc/configuration-enc.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,37 @@ For example, when compiling the catalog for `some-node.github.net`, Puppet will
6767
```
6868
6969
Sometimes the ENC script requires credentials or makes other assumptions about the system on which it is running. To be able to run the ENC script on systems other than your Puppet master, you will need to ensure that any such credentials are supplied and other assumptions are met.
70+
71+
## Environment
72+
73+
When the ENC is executed, the following environment variables are set to match the environment of the shell in which octocatalog-diff executes:
74+
75+
- `HOME`
76+
- `PATH`
77+
- `PWD` (set to the temporary directory as previously described)
78+
79+
No other environment variables are passed from the shell. If you wish to pass additional environment variables, you must explicitly list them with the `--pass-env-vars` CLI flag or `settings[:pass_env_vars]` array in your configuration file.
80+
81+
As an example, consider that your ENC is written in Python, and needs the `PYTHONPATH` variable set to `/usr/local/lib/python-custom`. Even if this environment variable is set when octocatalog-diff is run, it will not be available to the ENC script. You may pass the variable via the command line:
82+
83+
```
84+
octocatalog-diff --pass-env-vars PYTHONPATH ...
85+
```
86+
87+
Or you may specify it in your configuration file:
88+
89+
```
90+
settings[:pass_env_vars] = [ 'PYTHONPATH' ]
91+
```
92+
93+
If you wish to specify multiple environment variables to pass:
94+
95+
```
96+
octocatalog-diff --pass-env-vars PYTHONPATH,SECONDVAR,THIRDVAR ...
97+
```
98+
99+
or
100+
101+
```
102+
settings[:pass_env_vars] = [ 'PYTHONPATH', 'SECONDVAR', 'THIRDVAR' ]
103+
```

0 commit comments

Comments
 (0)