From 5d701a92fd11b6b6784dc00d2fa4a6dae8b64600 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Wed, 13 Feb 2019 18:35:47 +0100 Subject: [PATCH] F #2645: Fix some errors in ansible parse output (#2935) --- src/oneprovision/lib/ansible.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/oneprovision/lib/ansible.rb b/src/oneprovision/lib/ansible.rb index 3077293ab7..7efc6affe5 100644 --- a/src/oneprovision/lib/ansible.rb +++ b/src/oneprovision/lib/ansible.rb @@ -97,7 +97,9 @@ module OneProvision Utils.fail('Hosts are already configured') end - configure_all(hosts) + Driver.retry_loop 'Failed to configure hosts' do + configure_all(hosts) + end end # TODO: expect multiple hosts @@ -206,9 +208,13 @@ module OneProvision host = Regexp.last_match(1) begin - text = JSON.parse(Regexp.last_match(2))['msg'] - .strip.tr("\n", ' ') - text = "- #{text}" + match = JSON.parse(Regexp.last_match(2)) + + msg = match['msg'] + msg = match['reason'] if msg.nil? + + text = msg.strip.tr("\n", ' ') + text = "- #{text}" rescue StandardError => e raise e end @@ -216,8 +222,9 @@ module OneProvision host = Regexp.last_match(1) end - rtn << format('- 15%s : TASK[%s] %s', - :h => host, :t => task, :tx => text) + content = { :h => host, :t => task, :tx => text } + + rtn << format('- %s : TASK[%s] %s', content) end rtn.join("\n")