foreman_ansible 10.4.2 → 10.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/foreman/controller/parameters/job_template_extensions.rb +17 -0
- data/app/controllers/foreman_ansible/api/v2/job_templates_controller_extensions.rb +18 -0
- data/app/models/foreman_ansible/ansible_provider.rb +1 -1
- data/app/views/api/v2/job_templates/job_templates.json.rabl +3 -0
- data/app/views/job_templates/_job_template_callback_tab_content.html.erb +3 -0
- data/app/views/job_templates/_job_template_callback_tab_headers.html.erb +13 -0
- data/db/migrate/20221003153000_add_ansible_callback_enabled_to_templates.rb +10 -0
- data/lib/foreman_ansible/engine.rb +3 -0
- data/lib/foreman_ansible/register.rb +14 -0
- data/lib/foreman_ansible/version.rb +1 -1
- data/test/unit/ansible_provider_test.rb +3 -4
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 43677522138ced457422019bc60d466cc4ff22956ce56cf35c6fad5bc6227aae
|
|
4
|
+
data.tar.gz: a1523c4616c40ee68cd0209668d34f6a8ae20a817742181ca71f54580b38706f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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,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
|
|
@@ -12,16 +12,15 @@ class AnsibleProviderTest < ActiveSupport::TestCase
|
|
|
12
12
|
assert command_options['ansible_inventory']
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
context 'when
|
|
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
|
|
21
|
+
context 'when ansible_callback_enabled is set to true' do
|
|
22
22
|
it 'has remote_execution_command false' do
|
|
23
|
-
|
|
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.
|
|
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-
|
|
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
|