mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -07:00
Introduce per task variables and push them to templates.
This commit is contained in:
parent
edd5baad8b
commit
ab86726a15
3 changed files with 38 additions and 8 deletions
|
@ -48,7 +48,7 @@ for x in items:
|
|||
source = params['src']
|
||||
dest = params['dest']
|
||||
metadata = params.get('metadata', '/etc/ansible/setup')
|
||||
|
||||
module_vars = params.get('vars')
|
||||
|
||||
# raise an error if there is no template metadata
|
||||
if not os.path.exists(metadata):
|
||||
|
@ -71,6 +71,19 @@ except:
|
|||
})
|
||||
sys.exit(1)
|
||||
|
||||
if module_vars:
|
||||
try:
|
||||
f = open(module_vars)
|
||||
vars = json.loads(f.read())
|
||||
data.update(vars)
|
||||
f.close()
|
||||
except:
|
||||
print json.dumps({
|
||||
"failed" : 1,
|
||||
"msg" : "Failed to parse/load %s." % module_vars
|
||||
})
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.exists(source):
|
||||
print json.dumps({
|
||||
"failed" : 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue