mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-25 07:21:43 -07:00
Doc custom facts
This commit is contained in:
parent
d9fe6e959b
commit
c193f774c2
1 changed files with 25 additions and 1 deletions
|
@ -166,9 +166,33 @@ Let's test that module::
|
||||||
|
|
||||||
This should return something like::
|
This should return something like::
|
||||||
|
|
||||||
{"changed": true, "time": "2012-03-14 12:23:00.000307"}
|
{"changed": True, "time": "2012-03-14 12:23:00.000307"}
|
||||||
|
|
||||||
|
|
||||||
|
Module Provided 'Facts'
|
||||||
|
```````````````````````
|
||||||
|
|
||||||
|
The 'setup' module that ships with Ansible provides many variables about a system that can be used in playbooks
|
||||||
|
and templates. However, it's possible to also add your own facts without modifying the system module. To do
|
||||||
|
this, just have the module return a `ansible_facts` key, like so, along with other return data. This requires
|
||||||
|
Ansible 0.4 and later::
|
||||||
|
|
||||||
|
{
|
||||||
|
"changed" : True,
|
||||||
|
"rc" : 5,
|
||||||
|
"ansible_facts" : {
|
||||||
|
"leptons" : 5000
|
||||||
|
"colors" : {
|
||||||
|
"red" : "FF0000",
|
||||||
|
"white" : "FFFFFF"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
These 'facts' will be available to all statements called after that module (but not before) in the playbook.
|
||||||
|
A good idea might be make a module called 'site_facts' and always call it at the top of each playbook, though
|
||||||
|
we're always open to improving the selection of core facts in Ansible as well.
|
||||||
|
|
||||||
Common Pitfalls
|
Common Pitfalls
|
||||||
```````````````
|
```````````````
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue