From b743114f7ae8b1a54ec585b7c6b23287f6c073d0 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Thu, 14 Jun 2018 07:41:46 +0200 Subject: [PATCH] Use AwesomeSpawn to call the ansible command --- lib/ansible/runner.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/ansible/runner.rb b/lib/ansible/runner.rb index b9346598f770..38661073625c 100644 --- a/lib/ansible/runner.rb +++ b/lib/ansible/runner.rb @@ -8,22 +8,14 @@ def run(env_vars, extra_vars, playbook_path) private def run_via_cli(env_vars, extra_vars, playbook_path) - result = %x(#{format_env_vars(env_vars)} #{ansible_command.shellescape} #{format_extra_vars(extra_vars)} #{playbook_path.to_s.shellescape}) - JSON.parse(result) + result = AwesomeSpawn.run!(ansible_command, :env => env_vars, :params => [{:extra_vars => JSON.dump(extra_vars)}, playbook_path]) + JSON.parse(result.output) end def ansible_command # TODO add possibility to use custom path, e.g. from virtualenv "ansible-playbook" end - - def format_env_vars(env_vars) - env_vars.map { |key, value| "#{key.shellescape}='#{value.shellescape}'" }.join(" ") - end - - def format_extra_vars(extra_vars) - "--extra-vars '#{JSON.dump(extra_vars)}'" - end end end end