Merge pull request #38799 from aosagie/fix-ansible-dynamic-roster

Parse ansible dynamic inventory output correctly
This commit is contained in:
Mike Place 2017-01-18 08:32:47 -07:00 committed by GitHub
commit e3ca6881c8

View File

@ -46,18 +46,14 @@ There is also the option of specifying a dynamic inventory, and generating it on
#!/bin/bash
echo '{
"servers": {
"hosts": [
"salt.gtmanfred.com"
]
},
"desktop": {
"hosts": [
"home"
]
},
"servers": [
"salt.gtmanfred.com"
],
"desktop": [
"home"
],
"computers": {
"hosts":{},
"hosts": [],
"children": [
"desktop",
"servers"
@ -257,6 +253,8 @@ class Script(Target):
for key, value in six.iteritems(self.inventory):
if key == '_meta':
continue
if type(value) is list:
self._parse_groups(key, value)
if 'hosts' in value:
self._parse_groups(key, value['hosts'])
if 'children' in value:
@ -277,7 +275,8 @@ class Script(Target):
if server not in host:
host[server] = dict()
for tmpkey, tmpval in six.iteritems(tmp):
host[server][CONVERSION[tmpkey]] = tmpval
if tmpkey in CONVERSION:
host[server][CONVERSION[tmpkey]] = tmpval
if 'sudo' in host[server]:
host[server]['passwd'], host[server]['sudo'] = host[server]['sudo'], True