Skip to content

Commit d67b3d2

Browse files
bnericksonnofaralfasi
authored andcommitted
Fixes #37942 - Add job_check_mode to allow Ansible Check Mode in Job Templates
1 parent 833f457 commit d67b3d2

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
@@ -22,6 +22,7 @@ def initialize(input, suspended_action:, id: nil)
2222
@verbosity_level = action_input[:verbosity_level]
2323
@rex_command = action_input[:remote_execution_command]
2424
@check_mode = action_input[:check_mode]
25+
@job_check_mode = action_input[:job_check_mode]
2526
@tags = action_input[:tags]
2627
@tags_flag = action_input[:tags_flag]
2728
@passphrase = action_input['secrets']['key_passphrase']
@@ -224,7 +225,11 @@ def tags_cmd
224225
end
225226

226227
def check_cmd
227-
check_mode? ? '"--check"' : ''
228+
if check_mode? || job_check_mode?
229+
'"--check"'
230+
else
231+
''
232+
end
228233
end
229234

230235
def verbosity
@@ -239,6 +244,10 @@ def check_mode?
239244
@check_mode == true && @rex_command == false
240245
end
241246

247+
def job_check_mode?
248+
@job_check_mode == true
249+
end
250+
242251
def prepare_directory_structure
243252
inner = %w[inventory project env].map { |part| File.join(@root, part) }
244253
([@root] + inner).each do |path|

test/fixtures/action_input.json

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

0 commit comments

Comments
 (0)