You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Plugins in Modules]: /docs/puppet/latest/plugins_in_modules.html
8
-
[Adding plug-ins to a module]: /docs/puppet/latest/plugins_in_modules.html#adding-plug-ins-to-a-module
6
+
[Plugins in Modules]: /openvox/latest/plugins_in_modules.html
7
+
[Adding plug-ins to a module]: /openvox/latest/plugins_in_modules.html
8
+
[Facts overview]: ./fact_overview.html
9
9
10
-
You can add custom facts by writing snippets of Ruby code on the Puppet master. Puppet then uses [Plugins in Modules][] to distribute the facts to the client.
10
+
You can add custom facts by adding snippets of Ruby code to the OpenVox server. OpenVox then uses [Plugins in Modules][] to distribute the facts to all agents.
11
11
12
12
For information on how to add custom facts to modules, see [Adding plug-ins to a module][].
13
13
14
14
## Adding custom facts to OpenFact
15
15
16
16
Sometimes you need to be able to write conditional expressions based on site-specific data that just isn't available via OpenFact, or perhaps you'd like to include it in a template.
17
17
18
-
Because you can't include arbitrary Ruby code in your manifests, the best solution is to add a new fact to OpenFact. These additional facts can then be distributed to Puppet clients and are available for use in manifests and templates, just like any other fact is.
18
+
Because you can't include arbitrary Ruby code in your manifests, the best solution is to add a new fact to OpenFact. These additional facts can then be distributed to OpenVox agent and are available for use in manifests and templates, just like any other fact is.
19
19
20
-
> **Note:**Facter 3.0 removed the Ruby implementations of some features and replaced them with a [custom facts API](https://github.com/puppetlabs/facter/blob/master/Extensibility.md#custom-facts-compatibility). Any custom fact that requires one of the Ruby files previously stored in `lib/facter/util` fails with an error. For more information, see the [Facter 3.0 release notes](../3.0/release_notes.html).
20
+
> **Note:**OpenFact provides a [custom facts API](https://github.com/openvoxproject/openfact/blob/master/Extensibility.md#custom-facts-compatibility).
21
21
22
22
## Loading custom facts
23
23
@@ -51,10 +51,11 @@ OpenFact can take multiple `--custom-dir` options on the command line that speci
51
51
to search for custom facts. OpenFact attempts to load all Ruby files in the specified directories.
@@ -65,23 +66,17 @@ OpenFact also checks the environment variable `FACTERLIB` for a delimited (semic
65
66
other platforms) set of directories, and tries to load all Ruby files in those directories.
66
67
This allows you to do something like this:
67
68
68
-
$ ls my_facts
69
-
system_load.rb
70
-
$ ls my_other_facts
71
-
users.rb
69
+
#~/my_facts
70
+
└── system_load.rb
71
+
#~/my_other_facts
72
+
└── users.rb
73
+
72
74
$ export FACTERLIB="./my_facts:./my_other_facts"
73
75
$ facter system_load users
74
76
system_load => 0.25
75
77
users => thomas,pat
76
78
77
-
> ### Note: Changes in built-in pluginsync support in Facter 3
78
-
>
79
-
> Facter 2.4 **deprecated** Facter's support for loading facts via Puppet's pluginsync
80
-
> (the `-p` option), and Facter 3.0.0 **removed** the `-p` option. However, we reversed
81
-
> this decision in Facter 3.0.2 and re-enabled the `-p` option. For details about current
82
-
> and future support for this option, see the [Facter 3.0.2 release notes][].
83
-
84
-
## Two parts of every fact
79
+
## Two parts of every custom fact
85
80
86
81
Most facts have at least two elements:
87
82
@@ -90,16 +85,20 @@ Most facts have at least two elements:
90
85
91
86
Facts *can* get a lot more complicated than that, but those two together are the most common implementation of a custom fact.
92
87
93
-
## Executing shell commands in facts
88
+
## Executing shell commands in custom facts
94
89
95
-
Puppet gets information about a system from OpenFact, and the most common way for OpenFact to
90
+
OpenVox gets information about a system from OpenFact, and the most simple way for OpenFact to
96
91
get that information is by executing shell commands. You can then parse and manipulate the
97
-
output from those commands using standard Ruby code. The OpenFact API gives you a few ways to
92
+
output from those commands using standard Ruby code.
93
+
94
+
> **Note:** However, it is important to also ceck if any of the OpenVox agent bundled Ruby Libraries can be used.
95
+
96
+
The OpenFact API gives you a few ways to
98
97
execute shell commands:
99
98
100
-
-To run a command and use the output verbatim, as your fact's value, you can pass the command into `setcode` directly. For example: `setcode 'uname --hardware-platform'`
101
-
-If your fact is more complicated than that, you can call `Facter::Core::Execution.execute('uname --hardware-platform')` from within the `setcode do`...`end` block. Whatever the `setcode` statement returns is used as the fact's value.
102
-
-Your shell command is also a Ruby string, so you need to escape special characters if you want to pass them through.
99
+
- To run a command and use the output verbatim, as your fact's value, you can pass the command into `setcode` directly. For example: `setcode 'uname --hardware-platform'`
100
+
- If your fact is more complicated than that, you can call `Facter::Core::Execution.execute('uname --hardware-platform')` from within the `setcode do`...`end` block. Whatever the `setcode` statement returns is used as the fact's value.
101
+
- Your shell command is also a Ruby string, so you need to escape special characters if you want to pass them through.
103
102
104
103
> **Note:** Not everything that works in the terminal works in a fact. You can use the pipe (`|`) and similar operators as you normally would, but Bash-specific syntax like `if` statements do not work. The best way to handle this limitation is to write your conditional logic in Ruby.
105
104
@@ -109,10 +108,10 @@ To get the output of `uname --hardware-platform` to single out a specific type o
109
108
110
109
1. Start by giving the fact a name, in this case, `hardware_platform`.
111
110
112
-
2. Create your new fact in a file, `hardware_platform.rb` on the Puppet master server:
111
+
2. Create your new fact in a file, `hardware_platform.rb` on an OpenVox agent system:
113
112
114
113
```ruby
115
-
#hardware_platform.rb
114
+
#~/my_facts/hardware_platform.rb
116
115
117
116
Facter.add('hardware_platform') do
118
117
setcode do
@@ -121,19 +120,19 @@ To get the output of `uname --hardware-platform` to single out a specific type o
121
120
end
122
121
```
123
122
124
-
3. Use the instructions in the [PluginsinModules][] page to copy the new fact to a module and distribute it. During your next Puppet run, the value of the new fact is available to use in your manifests and templates.
123
+
3. Use the instructions in the [PluginsinModules][] page to copy the new fact to a module and distribute it. During your next OpenVox run, the value of the new fact is available to use in your manifests and templates.
125
124
126
-
## Using other facts
125
+
## Accessing other facts
127
126
128
-
You can write a fact that uses other facts by accessing `Facter.value(:somefact)`.
127
+
You can write a custom fact that uses other facts by accessing `Facter.value(:somefact)`.
129
128
If the fact fails to resolve or is not present, OpenFact returns `nil`.
130
129
131
130
Forexample:
132
131
133
132
``` ruby
134
133
Facter.add(:osfamily) do
135
134
setcode do
136
-
distid = Facter.value(:lsbdistid)
135
+
distid = Facter.value(:os)['family']
137
136
case distid
138
137
when /RedHatEnterprise|CentOS|Fedora/
139
138
'redhat'
@@ -146,11 +145,11 @@ Facter.add(:osfamily) do
146
145
end
147
146
```
148
147
149
-
## Configuring facts
148
+
## Configuring custom facts
150
149
151
150
Facts have a few properties that you can use to customize how they are evaluated.
152
151
153
-
### Confining facts
152
+
### Confining custom facts
154
153
155
154
One of the more commonly used properties is the `confine` statement, which
156
155
restricts the fact to only run on systems that matches another given fact.
@@ -174,7 +173,9 @@ available on the given system. Since this is only available on Linux systems,
174
173
we use the `confine` statement to ensure that this fact isn't needlessly run on
175
174
systems that don't support this type of enumeration.
176
175
177
-
### Fact precedence
176
+
>**Note:**More information on other ways to confine. e.g. files present can be found a the [Facts overview]
177
+
178
+
### Custom facts precedence
178
179
179
180
A single fact can have multiple **resolutions**, each of which is a different way
180
181
of ascertaining what the value of the fact should be. It's very common to have
@@ -221,7 +222,9 @@ Facter.add(:role) do
221
222
end
222
223
```
223
224
224
-
### Execution timeouts
225
+
> **Hint:** A weight above 1000 overwrites external facts
226
+
227
+
### Custom facts execution timeouts
225
228
226
229
Although this version of OpenFact does not support overall timeouts on resolutions, you can pass a timeout
227
230
to `Facter::Core::Execution#execute`:
@@ -239,11 +242,11 @@ Facter.add(:sleep) do
239
242
end
240
243
```
241
244
242
-
## Structured facts
245
+
## Structured custom facts
243
246
244
247
Structured facts take the form of either a hash or an array. To create a structured fact, return a hash or an array from the `setcode` statement.
245
248
246
-
You can see some relevant examples in the [writing structured facts](./fact_overview.html#writing-structured-facts) section of the [Fact Overview](./fact_overview.html).
249
+
You can see some relevant examples in the [writing structured facts](./fact_overview.html#writing-structured-facts) section of the [Facts overview].
247
250
248
251
## Aggregate resolutions
249
252
@@ -287,21 +290,21 @@ end
287
290
288
291
If the `chunk` blocks all return arrays or hashes, you can omit the `aggregate` block. If you do, OpenFact automatically merges all of your data into one array or hash and uses that as the fact's value.
289
292
290
-
For more examples of aggregate resolutions, see the [aggregate resolutions](./fact_overview.html#writing-facts-with-aggregate-resolutions) section of the [Fact Overview](./fact_overview.html) page.
293
+
For more examples of aggregate resolutions, see the [aggregate resolutions](./fact_overview.html#writing-facts-with-aggregate-resolutions) section of the [Fact overview] page.
291
294
292
295
## Viewing fact values
293
296
294
-
[puppetdb]: /puppetdb/latest
297
+
[OpenVox-DB]: /openvoxdb/latest
295
298
296
-
If your Puppet masters are configured to use [PuppetDB][puppetdb], you can view and search all of the facts for any node, including custom facts. See [the PuppetDB docs][puppetdb] for more info.
299
+
If your Puppet masters are configured to use [OpenVox-DB][OpenVox-DB], you can view and search all of the facts for any node, including custom facts. See [the OpenVox-DB docs][openvoxdb] for more info.
297
300
298
301
## External facts
299
302
300
303
### What are external facts?
301
304
302
305
External facts provide a way to use arbitrary executables or scripts as facts, or set facts statically with structured data. If you've ever wanted to write a custom fact in Perl, C, or a one-line text file, this is how.
303
306
304
-
### Executable facts --- Unix
307
+
### Executable external facts --- Unix
305
308
306
309
Executable facts on Unix work by dropping an executable file into the standard
307
310
external fact path. A shebang (`#!`) is always required for executable facts on Unix. If the shebang is missing, the execution of the fact fails.
@@ -329,7 +332,7 @@ STDOUT in the format:
329
332
330
333
Using this format, a single script can return multiple facts.
331
334
332
-
### Executable facts --- Windows
335
+
### Executable external facts --- Windows
333
336
334
337
Executable facts on Windows work by dropping an executable file into the external fact path. Unlike with Unix, the external facts interface expects Windows scripts to end with a known extension. Line endings can be either `LF` or `CRLF`. The following extensions are currently supported:
335
338
@@ -345,11 +348,11 @@ As with Unix facts, each script must return key/value pairs on STDOUT in the for
345
348
346
349
Using this format, a single script can return multiple facts in one return.
347
350
348
-
#### Executable fact locations
351
+
#### Executable eternal fact locations
349
352
350
-
The best way to distribute external executable facts is with pluginsync, which added support for them in [Puppet 3.4] (/puppet/3/reference/release_notes.html#preparations-for-syncing-external-facts)/[Facter 2.0.1](../2.0/release_notes.html#pluginsync-for-external-facts). To add external executable facts to your Puppet modules, just place them in <MODULEPATH>/<MODULE>/facts.d/.
353
+
The best way to distribute external executable facts is with pluginsync, To add external executable facts to your OpenVox modules, just place them in <MODULEPATH>/<MODULE>/facts.d/.
351
354
352
-
If you're not using pluginsync, then external facts must go in a standard directory. The location of this directory varies depending on your operating system, whether your deployment uses Puppet Enterprise or open source releases, and whether you are running as root/Administrator. When calling facter from the command line, you can specify the external facts directory with the `--external-dir` option.
355
+
If you're not using pluginsync, then external facts must go in a standard directory. The location of this directory varies depending on your operating systemand whether you are running as root/Administrator. When calling OpenFact from the command line, you can specify the external facts directory with the `--external-dir` option.
353
356
354
357
> **Note:** These directories don't necessarily exist by default; you may need to create them. If you create the directory, make sure to restrict access so that only Administrators can write to the directory.
355
358
@@ -371,9 +374,9 @@ When running as a non-root / non-Administrator user:
371
374
372
375
<HOME DIRECTORY>/.facter/facts.d/
373
376
374
-
> **Note:** You can only use custom facts as a non-root user if you have first [configured non-root user access]({{pe}}/deploy_nonroot-agent.html) and previously run Puppet agent as that same user.
377
+
> **Note:** You can only use custom facts as a non-root user if you have previously run OpenVox agent as that same user.
375
378
376
-
#### Batch scripts
379
+
#### Windows batch scripts
377
380
378
381
The file encoding for `.bat/.cmd` files must be `ANSI` or `UTF8 without BOM` (Byte Order Mark), otherwise you may get strange output.
379
382
@@ -398,7 +401,7 @@ Here is a sample PowerShell script which outputs facts using the required format
398
401
399
402
You should be able to save and execute this PowerShell script on the command line.
400
403
401
-
### Structured data facts
404
+
### Structured data based external facts
402
405
403
406
OpenFact can parse structured data files stored in the external facts directory and set facts based on their contents.
404
407
@@ -433,7 +436,7 @@ key3=value3
433
436
434
437
As with executable facts, structured data files can set multiple facts at once.
435
438
436
-
```javascript
439
+
```json
437
440
{
438
441
"datacenter":
439
442
{
@@ -449,14 +452,14 @@ As with executable facts, structured data files can set multiple facts at once.
449
452
}
450
453
```
451
454
452
-
#### Structured data facts on Windows
455
+
#### Structured data based external facts on Windows
453
456
454
457
All of the above types are supported on Windows with the following caveats:
455
458
456
459
- The line endings can be either `LF` or `CRLF`.
457
460
- The file encoding must be either `ANSI` or `UTF8 without BOM` (Byte Order Mark).
458
461
459
-
### Troubleshooting
462
+
### Troubleshooting external facts
460
463
461
464
If your external fact is not appearing in OpenFact's output, running
462
465
OpenFact in debug mode should give you a meaningful reason and tell you which file is causing the problem:
@@ -489,7 +492,7 @@ found in the `stdlib` module.
489
492
490
493
### Drawbacks
491
494
492
-
While external facts provide a mostly-equal way to create variables for Puppet, they have a few drawbacks:
495
+
While external facts provide a mostly-equal way to create variables for OpenVox, they have a few drawbacks:
493
496
494
497
- An external fact cannot internally reference another fact. However, due to parse order, you can reference an external fact from a Ruby fact.
495
498
- External executable facts are forked instead of executed within the same process.
Copy file name to clipboardExpand all lines: docs/_openfact_5x/index.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,9 @@ title: "Documentation index"
5
5
6
6
OpenFact is OpenVox's cross-platform system profiling library. It discovers and reports per-node facts, which are available in your OpenVox manifests as variables.
7
7
8
-
*[The list of core facts](./core_facts.html) lists and describes every built-in fact that ships with OpenFact.
8
+
*[The OpenFact release notes](./release_notes.html) document OpenFact's history.
9
+
*[The CLI](./cli.html) lists and describes the command line interface usage and options for OpenFact (auto-generated).
10
+
*[The list of core facts](./core_facts.html) lists and describes every built-in fact that ships with OpenFact (auto-generated).
9
11
*[The custom fact reference](./fact_overview.html) serves as an example-driven primer and quick reference for fact authors.
10
12
*[The custom facts walkthrough](./custom_facts.html) explains in detail how to write and distribute your own custom or external facts.
11
-
*[The OpenFact release notes](./release_notes.html)document OpenFact's history.
13
+
*[The configuration file options](./configuring_openfact.html)explains in detail how to configure the behavior of OpenFact.
0 commit comments