mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #38799 from aosagie/fix-ansible-dynamic-roster
Parse ansible dynamic inventory output correctly
This commit is contained in:
commit
e3ca6881c8
@ -46,18 +46,14 @@ There is also the option of specifying a dynamic inventory, and generating it on
|
||||
|
||||
#!/bin/bash
|
||||
echo '{
|
||||
"servers": {
|
||||
"hosts": [
|
||||
"servers": [
|
||||
"salt.gtmanfred.com"
|
||||
]
|
||||
},
|
||||
"desktop": {
|
||||
"hosts": [
|
||||
],
|
||||
"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,6 +275,7 @@ class Script(Target):
|
||||
if server not in host:
|
||||
host[server] = dict()
|
||||
for tmpkey, tmpval in six.iteritems(tmp):
|
||||
if tmpkey in CONVERSION:
|
||||
host[server][CONVERSION[tmpkey]] = tmpval
|
||||
if 'sudo' in host[server]:
|
||||
host[server]['passwd'], host[server]['sudo'] = host[server]['sudo'], True
|
||||
|
Loading…
Reference in New Issue
Block a user