Skip to content

Commit c04b0f8

Browse files
Add Ansible diff mode
Add the possibility to turn on Ansible diff mode by the new input parameter diff_mode. Signed-off-by: Ruediger Pluem <ruediger.pluem@vodafone.com> Update lib/smart_proxy_ansible/runner/ansible_runner.rb Co-authored-by: Adam Růžička <adamruzicka@users.noreply.github.com>
1 parent 2231534 commit c04b0f8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-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+
@diff_mode = action_input[: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+
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 diff_mode?
257+
@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|

0 commit comments

Comments
 (0)