X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=website%2Freference%2Fplugins%2Ffacts.md;fp=website%2Freference%2Fplugins%2Ffacts.md;h=2ea58ffefa990eed3a6cb50a0c84c057a1b38165;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/website/reference/plugins/facts.md b/website/reference/plugins/facts.md new file mode 100644 index 0000000..2ea58ff --- /dev/null +++ b/website/reference/plugins/facts.md @@ -0,0 +1,82 @@ +--- +layout: default +title: Writing Fact Plugins +toc: false +--- +[SimpleRPCAuthorization]: /mcollective/simplerpc/authorization.html +[Registration]: registration.html + +Fact plugins are used during discovery whenever you run the agent with queries like *-W country=de*. + +The default setup uses a YAML file typically stored in */etc/mcollective/facts.yaml* to read facts. There are however many fact systems like Reductive Labs Facter and Opscode Ohai or you can come up with your own. The facts plugin type lets you write code to access these tools. + +Facts at the moment should be simple *variable = value* style flat Hashes, if you have a hierarchical fact system like Ohai you can flatten them into *var.subvar = value* style variables. + +## Details +Implementing a facts plugin is made simple by inheriting from *MCollective::Facts::Base*, in that case you just need to provide 1 method, the YAML plugin code can be seen below: + +For releases in the 1.0.x release cycle and older, use this plugin format: + +{% highlight ruby linenos %} +module MCollective + module Facts + require 'yaml' + + # A factsource that reads a hash of facts from a YAML file + class Yaml