From 8047ceceb3a975d4f9eebccd6e5518ee90849271 Mon Sep 17 00:00:00 2001 From: Ben Erickson Date: Wed, 23 Oct 2024 11:48:11 -0700 Subject: [PATCH] Fixes #37942 - Add job_check_mode to allow Ansible Check Mode in Job Templates --- lib/smart_proxy_ansible/runner/ansible_runner.rb | 11 ++++++++++- test/fixtures/action_input.json | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/smart_proxy_ansible/runner/ansible_runner.rb b/lib/smart_proxy_ansible/runner/ansible_runner.rb index c91e3ef..70bb670 100644 --- a/lib/smart_proxy_ansible/runner/ansible_runner.rb +++ b/lib/smart_proxy_ansible/runner/ansible_runner.rb @@ -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'] @@ -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 @@ -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| diff --git a/test/fixtures/action_input.json b/test/fixtures/action_input.json index 4c7485f..6f4ae6c 100644 --- a/test/fixtures/action_input.json +++ b/test/fixtures/action_input.json @@ -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,