0 votes
in DevOps by
Can I access environment variables with Facter in Puppet?

1 Answer

0 votes
by

I will suggest you to start this answer by saying:

Not directly. However, Facter reads in custom facts from a special subset of environment variables. Any environment variable with a prefix of FACTER_ will be converted into a fact when Facter runs.

Now explain the interviewer with an example:

1

2

3

4 $ FACTER_FOO=”bar”

 $ export FACTER_FOO</span>

 $ facter | grep  ‘foo’</span>

   foo => bar

The value of the FACTER_FOO environment variable would now be available in your Puppet manifests as $foo, and would have a value of ‘bar’. Using shell scripting to export an arbitrary subset of environment variables as facts is left as an exercise for the reader.

Related questions

0 votes
asked Oct 7, 2020 in Ansible by Robindeniel
0 votes
asked Nov 27, 2019 in DevOps by rajeshsharma
...