Tidy example inventories in "Developing Dynamic Inventory Sources" (#18758)

Thanks @adamchainz!
pull/4420/head
Adam Johnson 2017-04-20 17:36:16 +01:00 committed by scottb
parent fe9af903f3
commit f1c4b434cd
1 changed files with 24 additions and 21 deletions

View File

@ -19,22 +19,22 @@ Script Conventions
When the external node script is called with the single argument ``--list``, the script must output a JSON encoded hash/dictionary of all the groups to be managed to stdout. Each group's value should be either a hash/dictionary containing a list of each host/IP, potential child groups, and potential group variables, or simply a list of host/IP addresses, like so:: When the external node script is called with the single argument ``--list``, the script must output a JSON encoded hash/dictionary of all the groups to be managed to stdout. Each group's value should be either a hash/dictionary containing a list of each host/IP, potential child groups, and potential group variables, or simply a list of host/IP addresses, like so::
{ {
"databases" : { "databases": {
"hosts" : [ "host1.example.com", "host2.example.com" ], "hosts": ["host1.example.com", "host2.example.com"],
"vars" : { "vars": {
"a" : true "a": true
} }
}, },
"webservers" : [ "host2.example.com", "host3.example.com" ], "webservers": ["host2.example.com", "host3.example.com"],
"atlanta" : { "atlanta": {
"hosts" : [ "host1.example.com", "host4.example.com", "host5.example.com" ], "hosts": ["host1.example.com", "host4.example.com", "host5.example.com"],
"vars" : { "vars": {
"b" : false "b": false
}, },
"children": [ "marietta", "5points" ] "children": ["marietta", "5points"]
}, },
"marietta" : [ "host6.example.com" ], "marietta": ["host6.example.com"],
"5points" : [ "host7.example.com" ] "5points": ["host7.example.com"]
} }
.. versionadded:: 1.0 .. versionadded:: 1.0
@ -46,9 +46,9 @@ hash/dictionary, or a hash/dictionary of variables to make available to template
if the script does not wish to do this, printing an empty hash/dictionary is the way to go:: if the script does not wish to do this, printing an empty hash/dictionary is the way to go::
{ {
"favcolor" : "red", "favcolor": "red",
"ntpserver" : "wolf.example.com", "ntpserver": "wolf.example.com",
"monitoring" : "pack.example.com" "monitoring": "pack.example.com"
} }
.. _inventory_script_tuning: .. _inventory_script_tuning:
@ -74,13 +74,16 @@ The data to be added to the top level JSON dictionary looks like this::
# results of inventory script as above go here # results of inventory script as above go here
# ... # ...
"_meta" : { "_meta": {
"hostvars" : { "hostvars": {
"moocow.example.com" : { "asdf" : 1234 }, "moocow.example.com": {
"llama.example.com" : { "asdf" : 5678 } "asdf" : 1234
},
"llama.example.com": {
"asdf": 5678
}
} }
} }
} }
.. seealso:: .. seealso::