foreman_ansible 10.4.2 → 10.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d5fe936def15be1cc84456bb6d1fa5df9a5a895c2aea3da888908dbaa59c6fb
4
- data.tar.gz: 7cb834bfefdcfc73743d06c06e70b61965bd49d3b5aa263963ec7998d4ab70dc
3
+ metadata.gz: 43677522138ced457422019bc60d466cc4ff22956ce56cf35c6fad5bc6227aae
4
+ data.tar.gz: a1523c4616c40ee68cd0209668d34f6a8ae20a817742181ca71f54580b38706f
5
5
  SHA512:
6
- metadata.gz: 437ca9c045cb2e07982d4ca9a73913d80a8f155c1d5f5324e29f544554a3defddbf1295ee1093ac5cbbf87f60cb18981be394c26df7466c4b53943f77da99f23
7
- data.tar.gz: 5eb239a127d53b9b97b9a7bc2a6145f7bb96af3e8d3cb079b6b6e8d546b48ba441273062258429c8b35cfa3c387e993996e91a9d95a18b8300f8d9eaea1ddb80
6
+ metadata.gz: a513cd384608bf244807afc825d8f0db7e1984fbd1acc836cff5d4a35fbbcdb2163d56dea7927f5ff76c3b49dc3c2d9a84c21a0e0946f821058944054b15ba9a
7
+ data.tar.gz: 271871a432184fc08437e02cac8fc5a7389f9cb1a475727d96aa2870fe8beb9b11e35b926771946d48df9e13de34e01130b4294f9b1a54bf6a7644a5fe43559d
@@ -0,0 +1,17 @@
1
+ module Foreman
2
+ module Controller
3
+ module Parameters
4
+ module JobTemplateExtensions
5
+ extend ActiveSupport::Concern
6
+
7
+ class_methods do
8
+ def job_template_params_filter
9
+ super.tap do |filter|
10
+ filter.permit :ansible_callback_enabled
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAnsible
4
+ module Api
5
+ module V2
6
+ # Extends the job_templates api controller to support creating/updating with ansible callback plugin
7
+ module JobTemplatesControllerExtensions
8
+ extend Apipie::DSL::Concern
9
+
10
+ update_api(:create, :update) do
11
+ param :job_template, Hash do
12
+ param :ansible_callback_enabled, :bool, :desc => N_('Enable the callback plugin for this template')
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -123,7 +123,7 @@ if defined? ForemanRemoteExecution
123
123
 
124
124
  def ansible_command?(template)
125
125
  template.remote_execution_features.
126
- where(:label => 'ansible_run_host').empty?
126
+ where(:label => 'ansible_run_host').empty? && !template.ansible_callback_enabled
127
127
  end
128
128
  end
129
129
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ attributes :ansible_callback_enabled
@@ -0,0 +1,3 @@
1
+ <div class="tab-pane" id="ansible_callback_enabled">
2
+ <%= checkbox_f f, :ansible_callback_enabled, :label => _('Enable Ansible Callback'), :disabled => @template.locked? %>
3
+ </div>
@@ -0,0 +1,13 @@
1
+ <li><a id="ansible_tab_header" href="#ansible_callback_enabled" data-toggle="tab"><%= _("Ansible") %></a></li>
2
+ <script type="text/javascript">
3
+ $(document).ready(function () {
4
+ var provider_type = $('#job_template_provider_type');
5
+ provider_type.change(setAnsibleTabVisibilityByProvider);
6
+ provider_type.change();
7
+
8
+ function setAnsibleTabVisibilityByProvider() {
9
+ var tab_header = $("#ansible_tab_header");
10
+ this.value === 'Ansible' ? tab_header.show() : tab_header.hide();
11
+ }
12
+ });
13
+ </script>
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddAnsibleCallbackEnabledToTemplates < ActiveRecord::Migration[6.0]
4
+ def change
5
+ add_column :templates, :ansible_callback_enabled, :boolean, default: false
6
+ RemoteExecutionFeature.where(label: 'ansible_run_host').each do |rex_feature|
7
+ Template.where(id: rex_feature.job_template_id).update_all(ansible_callback_enabled: true)
8
+ end
9
+ end
10
+ end
@@ -74,6 +74,9 @@ module ForemanAnsible
74
74
  ::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsControllerExtensions
75
75
  ::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsParamGroupExtensions
76
76
  ::ConfigReportImporter.include ForemanAnsible::AnsibleReportImporter
77
+ ::Api::V2::JobTemplatesController.include ForemanAnsible::Api::V2::JobTemplatesControllerExtensions
78
+ ::Api::V2::JobTemplatesController.include Foreman::Controller::Parameters::JobTemplateExtensions
79
+ ::JobTemplatesController.include Foreman::Controller::Parameters::JobTemplateExtensions
77
80
  ReportImporter.register_smart_proxy_feature('Ansible')
78
81
  rescue StandardError => e
79
82
  Rails.logger.warn "Foreman Ansible: skipping engine hook (#{e})"
@@ -237,6 +237,8 @@ Foreman::Plugin.register :foreman_ansible do
237
237
  register_report_origin 'Ansible', 'ConfigReport'
238
238
  end
239
239
 
240
+ extend_rabl_template 'api/v2/job_templates/show', 'api/v2/job_templates/job_templates'
241
+
240
242
  describe_host do
241
243
  multiple_actions_provider :ansible_hosts_multiple_actions
242
244
  end
@@ -257,4 +259,16 @@ Foreman::Plugin.register :foreman_ansible do
257
259
  :partial => 'foreman/smart_proxies/update_smart_proxy',
258
260
  :onlyif => ->(proxy, view) { view.can_update_proxy?(proxy) }
259
261
  end
262
+ extend_page('templates/_form') do |context|
263
+ context.add_pagelet :tab_headers,
264
+ :name => _('Ansible'),
265
+ :partial => 'job_templates/job_template_callback_tab_headers',
266
+ :onlyif => ->(subject, _view) { subject.is_a? JobTemplate }
267
+ end
268
+ extend_page('templates/_form') do |context|
269
+ context.add_pagelet :tab_content,
270
+ :name => _('Ansible'),
271
+ :partial => 'job_templates/job_template_callback_tab_content',
272
+ :onlyif => ->(subject, _view) { subject.is_a? JobTemplate }
273
+ end
260
274
  end
@@ -4,5 +4,5 @@
4
4
  # This way other parts of Foreman can just call ForemanAnsible::VERSION
5
5
  # and detect what version the plugin is running.
6
6
  module ForemanAnsible
7
- VERSION = '10.4.2'
7
+ VERSION = '10.4.3'
8
8
  end
@@ -12,16 +12,15 @@ class AnsibleProviderTest < ActiveSupport::TestCase
12
12
  assert command_options['ansible_inventory']
13
13
  end
14
14
 
15
- context 'when it is not using the ansible_run_host feature' do
15
+ context 'when ansible_callback_enabled is set to false' do
16
16
  it 'sets enables :remote_execution_command to true' do
17
17
  assert command_options[:remote_execution_command]
18
18
  end
19
19
  end
20
20
 
21
- context 'when it is using the ansible_run_host feature' do
21
+ context 'when ansible_callback_enabled is set to true' do
22
22
  it 'has remote_execution_command false' do
23
- rex_feature = RemoteExecutionFeature.where(:label => 'ansible_run_host', :name => 'Run Ansible roles').first_or_create
24
- template_invocation.template.remote_execution_features << rex_feature
23
+ template_invocation.template.ansible_callback_enabled = true
25
24
  assert_not command_options[:remote_execution_command]
26
25
  end
27
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.4.2
4
+ version: 10.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-24 00:00:00.000000000 Z
11
+ date: 2023-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_list
@@ -86,10 +86,12 @@ files:
86
86
  - app/controllers/api/v2/ansible_variables_controller.rb
87
87
  - app/controllers/concerns/foreman/controller/parameters/ansible_override_value.rb
88
88
  - app/controllers/concerns/foreman/controller/parameters/ansible_variable.rb
89
+ - app/controllers/concerns/foreman/controller/parameters/job_template_extensions.rb
89
90
  - app/controllers/foreman_ansible/api/v2/hostgroups_controller_extensions.rb
90
91
  - app/controllers/foreman_ansible/api/v2/hostgroups_param_group_extensions.rb
91
92
  - app/controllers/foreman_ansible/api/v2/hosts_controller_extensions.rb
92
93
  - app/controllers/foreman_ansible/api/v2/hosts_param_group_extensions.rb
94
+ - app/controllers/foreman_ansible/api/v2/job_templates_controller_extensions.rb
93
95
  - app/controllers/foreman_ansible/concerns/api_common.rb
94
96
  - app/controllers/foreman_ansible/concerns/hostgroups_controller_extensions.rb
95
97
  - app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
@@ -172,6 +174,7 @@ files:
172
174
  - app/views/api/v2/ansible_variables/show.json.rabl
173
175
  - app/views/api/v2/hostgroups/ansible_roles.json.rabl
174
176
  - app/views/api/v2/hosts/ansible_roles.json.rabl
177
+ - app/views/api/v2/job_templates/job_templates.json.rabl
175
178
  - app/views/foreman/smart_proxies/_update_smart_proxy.html.erb
176
179
  - app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb
177
180
  - app/views/foreman_ansible/ansible_roles/_select_tab_title.html.erb
@@ -199,6 +202,8 @@ files:
199
202
  - app/views/foreman_ansible/job_templates/service_action_-_ansible_default.erb
200
203
  - app/views/foreman_ansible/job_templates/service_action_-_enable_web_console.erb
201
204
  - app/views/foreman_ansible/job_templates/smart_proxy_upgrade_-_ansible_default.erb
205
+ - app/views/job_templates/_job_template_callback_tab_content.html.erb
206
+ - app/views/job_templates/_job_template_callback_tab_headers.html.erb
202
207
  - app/views/ui_ansible_roles/index.json.rabl
203
208
  - app/views/ui_ansible_roles/main.json.rabl
204
209
  - app/views/ui_ansible_roles/show.json.rabl
@@ -218,6 +223,7 @@ files:
218
223
  - db/migrate/20200421201839_update_ansible_inv_template_name.rb
219
224
  - db/migrate/20210120150019_add_position_to_ansible_role.rb
220
225
  - db/migrate/20210818083407_fix_ansible_setting_category_to_dsl.rb
226
+ - db/migrate/20221003153000_add_ansible_callback_enabled_to_templates.rb
221
227
  - db/migrate/20221031114720_rename_capsule_upgrade_playbook.rb
222
228
  - db/seeds.d/100_common_parameters.rb
223
229
  - db/seeds.d/62_ansible_proxy_feature.rb