From 1541eaafa98fb82f3495789d84cb099269523c02 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Thu, 22 Apr 2021 21:25:44 -0400 Subject: [PATCH] Quote -e arg in ansible-playbook-command.sh When ansible-playbook-command.sh is generated, the argument to -e is an inlined JSON dict. In order for the script to parse this a s ginle argument, it needs to be single quoted. Change-Id: I750d780a8b091804fbde77db3d275c081d13bdf8 Signed-off-by: James Slagle --- tripleoclient/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index c9cacafe7..3bcb7e80b 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -696,7 +696,10 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None, for key, value in r_opts['envvars'].items(): f.write('export {}="{}"\n'.format(key, value)) f.write('echo -e "Running Ansible command"\n') - f.write('{} "$@"\n'.format(' '.join(runner_config.command))) + args = '{} "$@"\n'.format(' '.join(runner_config.command)) + # Single quote the dict passed to -e + args = re.sub('({.*})', '\'\\1\'', args) + f.write(args) os.chmod(command_path, 0o750) try: