foreman_ansible 10.4.2 → 10.4.4

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: fafa20eedfebfae90bd8eb981b1879ef7444f4f3a661d2ddb65231df477d6901
4
+ data.tar.gz: 60f8a8ad775ade5183c9fe3cf4374210e8e6dc93613970fe8c46a6de6ff58ad9
5
5
  SHA512:
6
- metadata.gz: 437ca9c045cb2e07982d4ca9a73913d80a8f155c1d5f5324e29f544554a3defddbf1295ee1093ac5cbbf87f60cb18981be394c26df7466c4b53943f77da99f23
7
- data.tar.gz: 5eb239a127d53b9b97b9a7bc2a6145f7bb96af3e8d3cb079b6b6e8d546b48ba441273062258429c8b35cfa3c387e993996e91a9d95a18b8300f8d9eaea1ddb80
6
+ metadata.gz: 64e4ff37e73336ed4cf530d1050ae75f0c6c4a86736e8ed0ea1b89742727672b43a3b8165fd946f0aa0eb75d2b1a514f43ac77f38cc94c436bf27b86e427a671
7
+ data.tar.gz: cfb54327ff40818064d3225b77d2d8ce89f6f36880323e76df44cf366acd61b7b5fb03e584c1e3119b447a7d3a07690d2c3218d3945fc28e3e514bc23f6a8aed
@@ -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.4'
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
@@ -4,8 +4,13 @@ import { sprintf, translate as __ } from 'foremanReact/common/I18n';
4
4
 
5
5
  import { showToast } from '../../../../toastHelper';
6
6
 
7
- const formatSourceLink = currentValue =>
8
- `${__(currentValue.element)}: ${currentValue.elementName}`;
7
+ function formatSourceLink(currentValue) {
8
+ const element =
9
+ typeof currentValue.element !== 'string'
10
+ ? currentValue.element.toString()
11
+ : currentValue.element;
12
+ return `${__(element)}: ${currentValue.elementName}`;
13
+ }
9
14
 
10
15
  export const formatSourceAttr = variable =>
11
16
  variable.currentValue
@@ -19,7 +19,7 @@ import {
19
19
  const TestComponent = withRedux(withMockedProvider(AnsibleVariableOverrides));
20
20
 
21
21
  describe('AnsibleVariableOverrides', () => {
22
- it('should show skeleton when page is loading', () => {
22
+ it('should show skeleton when page is loading', async () => {
23
23
  const { container } = render(
24
24
  <TestComponent
25
25
  hostId={hostId}
@@ -31,6 +31,8 @@ describe('AnsibleVariableOverrides', () => {
31
31
  expect(
32
32
  container.getElementsByClassName('react-loading-skeleton')
33
33
  ).toHaveLength(5);
34
+
35
+ await waitFor(tick);
34
36
  });
35
37
  it('should load', async () => {
36
38
  render(
@@ -26,7 +26,6 @@ class AnsibleRolesSwitcher extends React.Component {
26
26
  inheritedRoleIds,
27
27
  resourceId,
28
28
  resourceName,
29
- { page: 1, perPage: 10 },
30
29
  excludeAssignedRolesSearch(initialAssignedRoles)
31
30
  );
32
31
  }
@@ -19,7 +19,9 @@ const AvailableRolesList = ({
19
19
  <Pagination
20
20
  viewType="list"
21
21
  itemCount={itemCount}
22
- pagination={pagination}
22
+ updateParamsByUrl={false}
23
+ page={pagination.page}
24
+ perPage={pagination.perPage}
23
25
  onChange={onListingChange}
24
26
  dropdownButtonId="available-ansible-roles-pagination-row-dropdown"
25
27
  />
@@ -16,14 +16,8 @@ exports[`AvailableRolesList should render 1`] = `
16
16
  onPerPageSelect={null}
17
17
  onSetPage={null}
18
18
  page={1}
19
- pagination={
20
- Object {
21
- "page": 1,
22
- "perPage": 25,
23
- }
24
- }
25
- perPage={null}
26
- updateParamsByUrl={true}
19
+ perPage={25}
20
+ updateParamsByUrl={false}
27
21
  variant="bottom"
28
22
  viewType="list"
29
23
  />
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.4
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-08-21 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
@@ -493,9 +499,9 @@ test_files:
493
499
  - test/test_plugin_helper.rb
494
500
  - test/unit/ansible_role_test.rb
495
501
  - test/unit/ansible_variable_test.rb
502
+ - test/unit/concerns/config_reports_extensions_test.rb
496
503
  - test/unit/concerns/host_managed_extensions_test.rb
497
504
  - test/unit/concerns/hostgroup_extensions_test.rb
498
- - test/unit/concerns/config_reports_extensions_test.rb
499
505
  - test/unit/helpers/ansible_reports_helper_test.rb
500
506
  - test/unit/host_ansible_role_test.rb
501
507
  - test/unit/hostgroup_ansible_role_test.rb