Possibilité d'utiliser validate inquirerpy
This commit is contained in:
parent
d50569dd9c
commit
8e30083bc7
1 changed files with 4 additions and 2 deletions
|
@ -8,6 +8,9 @@ def runAnsiblePlaybook(config, key, extra_vars={}):
|
|||
if 'questions' in config['ansible_playbooks'][key]:
|
||||
for question in config['ansible_playbooks'][key]['questions'].copy():
|
||||
var_name = question.pop('var_name')
|
||||
# Si on a une fonction de validation dans le dictionnaire, alors on remplace la lambda sous forme de chaine par la fonction
|
||||
if 'validate' in question:
|
||||
question['validate'] = eval(question['validate'])
|
||||
extra_vars[var_name] = prompt(question)[0]
|
||||
|
||||
if 'extra_vars' in config['ansible_playbooks'][key]:
|
||||
|
@ -34,7 +37,6 @@ def runLocalAnsiblePlaybook(playbook, chdir, extra_vars={}):
|
|||
def runPulledAnsiblePlaybook(playbook, url, extra_vars={}):
|
||||
if len(extra_vars) > 0:
|
||||
subprocess.check_call(['ansible-playbook', playbook,
|
||||
'--extra-vars', json.dumps(extra_vars) ],
|
||||
cwd=chdir)
|
||||
'--extra-vars', json.dumps(extra_vars) ])
|
||||
else:
|
||||
subprocess.check_call(['ansible-pull', '-U', url, playbook])
|
||||
|
|
Loading…
Reference in a new issue