Facter via YAML¶
Overview¶
This method of accessing facts is what we recommend for Puppet users, it’s faster and deals better with some strange issues in Facter.
Essentially we use Puppet to dump the data it gathers during normal runs into a YAML file and just use the MCollective YAML fact source to read this data. This avoids an extreme slowdown from Facter running on every mcollective invocation, plus it lets you get any in-scope variables (for example, parameters from your external node classifier) available as mcollective filters for free.
Creating the YAML¶
In your Puppet manifests create a file resource similar to below:
file{"/etc/mcollective/facts.yaml":
owner => root,
group => root,
mode => 400,
loglevel => debug, # this is needed to avoid it being logged and reported on every run
# avoid including highly-dynamic facts as they will cause unnecessary template writes
content => inline_template("<%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime_seconds|timestamp|free)/ }.to_yaml %>")
}
Apply this to all the nodes that run MCollective.
Configure MCollective¶
Add the following lines to server.cfg
factsource = yaml plugin.yaml = /etc/mcollective/facts.yaml
Verify¶
% mc-inventory some.node
Inventory for some.node:
Server Statistics:
Version: 0.4.10
Start Time: Mon Nov 29 16:38:28 +0000 2010
Config File: /etc/mcollective/server.cfg
Process ID: 5387
Total Messages: 9254
Messages Passed Filters: 6443
Messages Filtered: 2811
Replies Sent: 6442
Total Processor Time: 23.27 seconds
System Time: 6.19 seconds
Facts:
architecture => i386
clientcert => some.node
clientversion => 2.6.3
country => de