mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Parse ansible dynamic inventory output correctly
This commit is contained in:
parent
f7294dc85b
commit
26d6f699a7
1 changed files with 11 additions and 12 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue