Adding external facts
The Creating custom facts recipe describes how to add extra facts written in Ruby. You can also create facts from simple files or from scripts with external facts instead. External facts may be written in YAML, JSON, or txt format.
External facts live in the /etc/facter/facts.d
directory and have a simple key=value
format:
message="Hello, world"
Getting ready
Here's what you need to do to prepare your system to add external facts.
You'll need to create the external facts
directory, using the following command:
[root@cookbook ~]# mkdir -p /etc/facter/facts.d
How to do it...
In this example, we'll create a simple external fact that returns a message, as shown in the Creating custom facts recipe:
- Create the
/etc/facter/facts.d/local.txt
file with the following contents:
model=ED-209
- Run the following command:
[root@cookbook ~]# facter model ED-209
- Well, that was easy! You can add more facts to the same file, or other files, of course, as follows:
model=ED-209 builder=OCP directives...