Skip to content

Commit 4e558d7

Browse files
committed
Fixes #38335 - Add job_diff_mode to allow Ansible Diff Mode in Job Templates
1 parent d67b3d2 commit 4e558d7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/smart_proxy_ansible/runner/ansible_runner.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def initialize(input, suspended_action:, id: nil)
2323
@rex_command = action_input[:remote_execution_command]
2424
@check_mode = action_input[:check_mode]
2525
@job_check_mode = action_input[:job_check_mode]
26+
@job_diff_mode = action_input[:job_diff_mode]
2627
@tags = action_input[:tags]
2728
@tags_flag = action_input[:tags_flag]
2829
@passphrase = action_input['secrets']['key_passphrase']
@@ -214,7 +215,7 @@ def start_ansible_runner
214215
end
215216

216217
def cmdline
217-
cmd_args = [tags_cmd, check_cmd].reject(&:empty?)
218+
cmd_args = [tags_cmd, check_cmd, diff_cmd].reject(&:empty?)
218219
return nil unless cmd_args.any?
219220
cmd_args.join(' ')
220221
end
@@ -232,6 +233,10 @@ def check_cmd
232233
end
233234
end
234235

236+
def diff_cmd
237+
job_diff_mode? ? '"--diff"' : ''
238+
end
239+
235240
def verbosity
236241
'-' + 'v' * @verbosity_level.to_i
237242
end
@@ -248,6 +253,10 @@ def job_check_mode?
248253
@job_check_mode == true
249254
end
250255

256+
def job_diff_mode?
257+
@job_diff_mode == true
258+
end
259+
251260
def prepare_directory_structure
252261
inner = %w[inventory project env].map { |part| File.join(@root, part) }
253262
([@root] + inner).each do |path|

test/fixtures/action_input.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"name": "test-00.example.com",
9393
"check_mode": false,
9494
"job_check_mode": false,
95+
"job_diff_mode": false,
9596
"hostname": "127.0.0.1",
9697
"script": "---\n- hosts: all\n tasks:\n - shell:\n cmd: |\n ls -la /\n register: out\n - debug: var=out",
9798
"execution_timeout_interval": null,

0 commit comments

Comments
 (0)