diff --git a/app/controllers/concerns/foreman/controller/parameters/job_template_extensions.rb b/app/controllers/concerns/foreman/controller/parameters/job_template_extensions.rb index 5bed2bff0..36f546614 100644 --- a/app/controllers/concerns/foreman/controller/parameters/job_template_extensions.rb +++ b/app/controllers/concerns/foreman/controller/parameters/job_template_extensions.rb @@ -7,7 +7,7 @@ module JobTemplateExtensions class_methods do def job_template_params_filter super.tap do |filter| - filter.permit :ansible_callback_enabled + filter.permit :ansible_callback_enabled, :ansible_check_mode end end end diff --git a/app/controllers/foreman_ansible/api/v2/job_templates_controller_extensions.rb b/app/controllers/foreman_ansible/api/v2/job_templates_controller_extensions.rb index 3930d5a3c..f973e5803 100644 --- a/app/controllers/foreman_ansible/api/v2/job_templates_controller_extensions.rb +++ b/app/controllers/foreman_ansible/api/v2/job_templates_controller_extensions.rb @@ -10,6 +10,7 @@ module JobTemplatesControllerExtensions update_api(:create, :update) do param :job_template, Hash do param :ansible_callback_enabled, :bool, :desc => N_('Enable the callback plugin for this template') + param :ansible_check_mode, :bool, :desc => N_('Enable Ansible Check Mode for this template') end end end diff --git a/app/models/foreman_ansible/ansible_provider.rb b/app/models/foreman_ansible/ansible_provider.rb index d151fa006..d725a95f2 100644 --- a/app/models/foreman_ansible/ansible_provider.rb +++ b/app/models/foreman_ansible/ansible_provider.rb @@ -32,7 +32,7 @@ def proxy_command_options(template_invocation, host) template_invocation.template ), :name => host.name, - :check_mode => host.host_param('ansible_roles_check_mode'), + :check_mode => check_mode?(template_invocation.template, host), :cleanup_working_dirs => cleanup_working_dirs?(host) ) end @@ -125,6 +125,10 @@ def ansible_command?(template) template.remote_execution_features. where(:label => 'ansible_run_host').empty? && !template.ansible_callback_enabled end + + def check_mode?(template, host) + host.host_param('ansible_roles_check_mode') || template.ansible_check_mode + end end end end diff --git a/app/views/api/v2/job_templates/job_templates.json.rabl b/app/views/api/v2/job_templates/job_templates.json.rabl index e3c5262fd..6037682ec 100644 --- a/app/views/api/v2/job_templates/job_templates.json.rabl +++ b/app/views/api/v2/job_templates/job_templates.json.rabl @@ -1,3 +1,3 @@ # frozen_string_literal: true -attributes :ansible_callback_enabled +attributes :ansible_callback_enabled, :ansible_check_mode diff --git a/app/views/job_templates/_job_template_callback_tab_content.html.erb b/app/views/job_templates/_job_template_callback_tab_content.html.erb index a3d7011b3..d180dbd2b 100644 --- a/app/views/job_templates/_job_template_callback_tab_content.html.erb +++ b/app/views/job_templates/_job_template_callback_tab_content.html.erb @@ -1,3 +1,4 @@