Reputation: 6120
I am slightly confused about external facts.
In the simplest form, I could create a json file in the facts.d folder and get it to work.
But I need it built dynamically, via some shell script which creates the json file. I have created the following and gotten it to work but I cannot tell whether this is the right way to do it:
shell script in the facts.d folder
cat <<END>some_facts.yaml
---
myfacts_array:
END
for file in `some folder`
do
echo " - $file" >>some_facts.yaml
done
The yaml file in turn looks like this
---
myfacts_array:
- 123456
- 456789
Is this the right way to achieve this?
Upvotes: 0
Views: 573
Reputation: 180201
Puppet relies on Facter for collecting facts, including external ones. Facter has supported structured, executable, external facts only since version 3.5, which is a little less than two years old. If your version of Facter is older, and you cannot upgrade, then you'll need to find a workaround, such as periodically writing a flat YAML or JSON file in the external facts directory.
If you do have a suitable version of Facter, then the script to execute must
If the script source you presented is meant to be a complete example then it is at least missing a shebang line, but the output appears to be correctly formed. Beyond that, I haven't any comment about whether what you present is "the right way" to do it.
* YAML or JSON is required to produce structured facts this way. For plain string facts you can instead output KEY
= VALUE
pairs, one per line.
Upvotes: 1