Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37942 - Add job_check_mode to allow Ansible Check Mode in Job Templates #94

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/smart_proxy_ansible/runner/ansible_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def initialize(input, suspended_action:, id: nil)
@verbosity_level = action_input[:verbosity_level]
@rex_command = action_input[:remote_execution_command]
@check_mode = action_input[:check_mode]
@job_check_mode = action_input[:job_check_mode]
@tags = action_input[:tags]
@tags_flag = action_input[:tags_flag]
@passphrase = action_input['secrets']['key_passphrase']
Expand Down Expand Up @@ -216,7 +217,11 @@ def tags_cmd
end

def check_cmd
check_mode? ? '"--check"' : ''
if check_mode? || job_check_mode?
'"--check"'
else
''
end
end

def verbosity
Expand All @@ -231,6 +236,10 @@ def check_mode?
@check_mode == true && @rex_command == false
end

def job_check_mode?
@job_check_mode == true
end

def prepare_directory_structure
inner = %w[inventory project env].map { |part| File.join(@root, part) }
([@root] + inner).each do |path|
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/action_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"remote_execution_command": true,
"name": "test-00.example.com",
"check_mode": false,
"job_check_mode": false,
"hostname": "127.0.0.1",
"script": "---\n- hosts: all\n tasks:\n - shell:\n cmd: |\n ls -la /\n register: out\n - debug: var=out",
"execution_timeout_interval": null,
Expand Down