From 6b3fe0bc0903a12da24610d139496203ef088eb1 Mon Sep 17 00:00:00 2001 From: Ruediger Pluem Date: Mon, 20 Jan 2025 15:40:48 +0100 Subject: [PATCH] fixes #38522 - Add Ansible diff mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the possibility to turn on Ansible diff mode by the new input parameter diff_mode. Signed-off-by: Ruediger Pluem Update lib/smart_proxy_ansible/runner/ansible_runner.rb Co-authored-by: Adam Růžička --- lib/smart_proxy_ansible/runner/ansible_runner.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/smart_proxy_ansible/runner/ansible_runner.rb b/lib/smart_proxy_ansible/runner/ansible_runner.rb index f56d1dd..074d3d2 100644 --- a/lib/smart_proxy_ansible/runner/ansible_runner.rb +++ b/lib/smart_proxy_ansible/runner/ansible_runner.rb @@ -23,6 +23,7 @@ def initialize(input, suspended_action:, id: nil) @rex_command = action_input[:remote_execution_command] @check_mode = action_input[:check_mode] @job_check_mode = action_input[:job_check_mode] + @diff_mode = action_input[:diff_mode] @tags = action_input[:tags] @tags_flag = action_input[:tags_flag] @passphrase = action_input['secrets']['key_passphrase'] @@ -214,7 +215,7 @@ def start_ansible_runner end def cmdline - cmd_args = [tags_cmd, check_cmd].reject(&:empty?) + cmd_args = [tags_cmd, check_cmd, diff_cmd].reject(&:empty?) return nil unless cmd_args.any? cmd_args.join(' ') end @@ -232,6 +233,10 @@ def check_cmd end end + def diff_cmd + diff_mode? ? '"--diff"' : '' + end + def verbosity '-' + 'v' * @verbosity_level.to_i end @@ -248,6 +253,10 @@ def job_check_mode? @job_check_mode == true end + def diff_mode? + @diff_mode == true + end + def prepare_directory_structure inner = %w[inventory project env].map { |part| File.join(@root, part) } ([@root] + inner).each do |path|