foreman_ansible 14.0.0 → 14.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/ansible_roles/import.html.erb +0 -1
- data/app/views/ansible_roles/index.html.erb +1 -1
- data/app/views/ansible_roles/welcome.html.erb +1 -1
- data/app/views/ansible_variables/_fields.erb +1 -1
- data/app/views/ansible_variables/index.html.erb +1 -2
- data/app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb +0 -1
- data/app/views/foreman_ansible/job_templates/convert_to_rhel.erb +17 -20
- data/db/seeds.d/90_notification_blueprints.rb +0 -13
- data/lib/foreman_ansible/register.rb +0 -2
- data/lib/foreman_ansible/remote_execution.rb +0 -8
- data/lib/foreman_ansible/version.rb +1 -1
- metadata +3 -9
- data/app/services/foreman_ansible/insights_notification_builder.rb +0 -64
- data/app/services/foreman_ansible/insights_plan_runner.rb +0 -86
- data/app/services/foreman_ansible/renderer_methods.rb +0 -46
- data/app/views/foreman_ansible/job_templates/maintenance_plan.erb +0 -19
- data/test/unit/services/insights_plan_runner_test.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4a545f421f2f2c43e19e841ccef12f519600a76d635455a78384bec421a5a83
|
4
|
+
data.tar.gz: 55ddd534490d785646a7cf7c88ba36c9e9e16502f8542615a184ecd1e00a2f02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d82a845c26ec335af11b373929b017cc112ef412463298c74d80efe432feb2062d51da39deacd4adc17eccc8ba17a1ac77ebd5915aaac222580b0f9d729b899
|
7
|
+
data.tar.gz: 317d0658cb5b25ae49036cddef2781b46c99bd380ebf3a59066ee6d2ee94ac6e32d7364ac0593ec7f6884bf738f7310a3ca0d4633f85bd015091b8dc8404eff8
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<% title _("Ansible Roles") %>
|
2
2
|
|
3
3
|
<% title_actions ansible_proxy_import(hash_for_import_ansible_roles_path),
|
4
|
-
documentation_button('
|
4
|
+
documentation_button('Managing_Configurations_Ansible', type: 'docs', chapter: 'Importing_Ansible_Roles_and_Variables_ansible') %>
|
5
5
|
|
6
6
|
<table class="<%= table_css_classes 'table-fixed' %>">
|
7
7
|
<thead>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<p><%= _('No Ansible Roles were found in Foreman. If you want to assign roles to your hosts,
|
8
8
|
you have to import them first.').html_safe %>
|
9
9
|
</p>
|
10
|
-
<p><%= link_to(_('Learn more about this in the documentation.'), documentation_url('
|
10
|
+
<p><%= link_to(_('Learn more about this in the documentation.'), documentation_url('Managing_Configurations_Ansible', type: 'docs', chapter: 'Importing_Ansible_Roles_and_Variables_ansible'), target: '_blank') %></p>
|
11
11
|
<div class="blank-slate-pf-secondary-action">
|
12
12
|
<%= ansible_proxy_import(hash_for_import_ansible_roles_path) %>
|
13
13
|
</div>
|
@@ -65,7 +65,7 @@
|
|
65
65
|
</fieldset>
|
66
66
|
</br>
|
67
67
|
<fieldset>
|
68
|
-
<h2><%= _("Specify Matchers") %> <%= documentation_button('
|
68
|
+
<h2><%= _("Specify Matchers") %> <%= documentation_button('Managing_Configurations_Ansible', type: 'docs', chapter: 'Overriding_Ansible_Variables_in_foreman_ansible') %></h2>
|
69
69
|
<div class="children_fields lookup_values">
|
70
70
|
<%= render 'lookup_keys/values', :f => f, :is_param => false %>
|
71
71
|
</div>
|
@@ -2,8 +2,7 @@
|
|
2
2
|
<%= stylesheet 'foreman_ansible/foreman-ansible' %>
|
3
3
|
|
4
4
|
<%= title_actions display_link_if_authorized(_('New Ansible Variable'), hash_for_new_ansible_variable_path, :class => "btn btn-default no-float"),
|
5
|
-
documentation_button('
|
6
|
-
%>
|
5
|
+
documentation_button('Managing_Configurations_Ansible', type: 'docs', chapter: 'Importing_Ansible_Roles_and_Variables_ansible') %>
|
7
6
|
|
8
7
|
<table class="<%= table_css_classes 'table-fixed' %>">
|
9
8
|
<thead>
|
@@ -19,22 +19,6 @@ template_inputs:
|
|
19
19
|
options: "yes\r\nno"
|
20
20
|
advanced: false
|
21
21
|
value_type: plain
|
22
|
-
resource_type: Katello::ActivationKey
|
23
|
-
hidden_value: false
|
24
|
-
- name: Data telemetry
|
25
|
-
required: true
|
26
|
-
input_type: user
|
27
|
-
description: "The convert2rhel utility uploads the following data about the system
|
28
|
-
conversion to Red Hat servers for the purpose of the utility usage analysis:<br>\r\n-
|
29
|
-
The convert2rhel command as executed<br>\r\n- The convert2rhel RPM version and
|
30
|
-
GPG signature<br>\r\n- Success or failure status of the conversion<br>\r\n- Conversion
|
31
|
-
start and end timestamps<br>\r\n- Source OS vendor and version<br>\r\n- Target
|
32
|
-
RHEL version<br>\r\n- convert2rhel related environment variables<br>"
|
33
|
-
options: "yes\r\nno"
|
34
|
-
advanced: false
|
35
|
-
value_type: plain
|
36
|
-
resource_type: Katello::ActivationKey
|
37
|
-
default: 'yes'
|
38
22
|
hidden_value: false
|
39
23
|
model: JobTemplate
|
40
24
|
job_category: Convert 2 RHEL
|
@@ -43,21 +27,34 @@ kind: job_template
|
|
43
27
|
%>
|
44
28
|
---
|
45
29
|
- hosts: all
|
46
|
-
<%- if input('Data telemetry') != "yes" -%>
|
47
30
|
environment:
|
48
|
-
|
49
|
-
<%- end -%>
|
31
|
+
CONVERT2RHEL_THROUGH_FOREMAN: 1
|
50
32
|
tasks:
|
51
33
|
- name: Install convert2rhel
|
52
34
|
ansible.builtin.package:
|
53
35
|
name: convert2rhel
|
54
36
|
state: present
|
37
|
+
|
38
|
+
- name: Gather package facts
|
39
|
+
package_facts:
|
40
|
+
manager: auto
|
41
|
+
|
42
|
+
- name: Set fact for package version
|
43
|
+
set_fact:
|
44
|
+
convert2rhel_version: "{{ ansible_facts.packages['convert2rhel'][0].version }}"
|
45
|
+
when: "'convert2rhel' in ansible_facts.packages"
|
46
|
+
no_log: true
|
47
|
+
|
55
48
|
- name: Prepopulate katello-ca-consumer
|
56
49
|
get_url:
|
57
50
|
url: <%= subscription_manager_configuration_url(@host) %>
|
58
51
|
dest: /usr/share/convert2rhel/subscription-manager/katello-ca-consumer-latest.noarch.rpm
|
52
|
+
when:
|
53
|
+
- "convert2rhel_version is version('2.0.0', '<')"
|
54
|
+
|
59
55
|
- name: Start convert2rhel
|
60
|
-
command: convert2rhel -y --activationkey "<%= input_resource('Activation Key').name %>" --org "<%= @host.organization.label %>"
|
56
|
+
command: convert2rhel -y --activationkey "<%= input_resource('Activation Key').name %>" --org "<%= @host.organization.label %>"
|
57
|
+
|
61
58
|
<%- if input('Restart') == "yes" -%>
|
62
59
|
- name: Reboot the machine
|
63
60
|
reboot:
|
@@ -1,19 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
blueprints = [
|
4
|
-
{
|
5
|
-
:group => N_('Jobs'),
|
6
|
-
:name => 'insights_remediation_successful',
|
7
|
-
:message => N_('Insights remediation on %{hosts_count}' \
|
8
|
-
' host(s) has finished successfully'),
|
9
|
-
:level => 'success',
|
10
|
-
:actions => {
|
11
|
-
:links => [
|
12
|
-
:path_method => :job_invocation_path,
|
13
|
-
:title => N_('Job Details')
|
14
|
-
]
|
15
|
-
}
|
16
|
-
},
|
17
4
|
{
|
18
5
|
:group => N_('Roles'),
|
19
6
|
:name => 'Sync_roles_and_variables_successfully',
|
@@ -178,8 +178,6 @@ Foreman::Plugin.register :foreman_ansible do
|
|
178
178
|
'Permissions required for the user which is used by Ansible Tower Dynamic Inventory Item'
|
179
179
|
|
180
180
|
add_all_permissions_to_default_roles
|
181
|
-
extend_template_helpers ForemanAnsible::RendererMethods
|
182
|
-
allowed_template_helpers :insights_remediation
|
183
181
|
|
184
182
|
base_role_assignment_params = { :ansible_role_ids => [],
|
185
183
|
:ansible_roles => [] }
|
@@ -22,14 +22,6 @@ module ForemanAnsible
|
|
22
22
|
' the roles defined for a host'),
|
23
23
|
:host_action_button => true
|
24
24
|
)
|
25
|
-
RemoteExecutionFeature.register(
|
26
|
-
:ansible_run_insights_plan,
|
27
|
-
N_('Ansible: Run Insights maintenance plan'),
|
28
|
-
:description => N_('Runs a given maintenance plan from Red Hat '\
|
29
|
-
'Access Insights given an ID.'),
|
30
|
-
:provided_inputs => %w[organization_id plan_id],
|
31
|
-
:notification_builder => ForemanAnsible::InsightsNotificationBuilder
|
32
|
-
)
|
33
25
|
RemoteExecutionFeature.register(
|
34
26
|
:ansible_run_playbook,
|
35
27
|
N_('Run playbook'),
|
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: 14.
|
4
|
+
version: 14.1.1
|
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: 2024-
|
11
|
+
date: 2024-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_list
|
@@ -171,14 +171,11 @@ files:
|
|
171
171
|
- app/services/foreman_ansible/import_playbooks_success_notification.rb
|
172
172
|
- app/services/foreman_ansible/import_roles_and_variables_error_notification.rb
|
173
173
|
- app/services/foreman_ansible/import_roles_and_variables_success_notification.rb
|
174
|
-
- app/services/foreman_ansible/insights_notification_builder.rb
|
175
|
-
- app/services/foreman_ansible/insights_plan_runner.rb
|
176
174
|
- app/services/foreman_ansible/inventory_creator.rb
|
177
175
|
- app/services/foreman_ansible/override_resolver.rb
|
178
176
|
- app/services/foreman_ansible/playbook_creator.rb
|
179
177
|
- app/services/foreman_ansible/playbooks_importer.rb
|
180
178
|
- app/services/foreman_ansible/proxy_api.rb
|
181
|
-
- app/services/foreman_ansible/renderer_methods.rb
|
182
179
|
- app/services/foreman_ansible/roles_importer.rb
|
183
180
|
- app/services/foreman_ansible/ui_roles_importer.rb
|
184
181
|
- app/services/foreman_ansible/variables_importer.rb
|
@@ -222,7 +219,6 @@ files:
|
|
222
219
|
- app/views/foreman_ansible/job_templates/ansible_windows_updates.erb
|
223
220
|
- app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb
|
224
221
|
- app/views/foreman_ansible/job_templates/convert_to_rhel.erb
|
225
|
-
- app/views/foreman_ansible/job_templates/maintenance_plan.erb
|
226
222
|
- app/views/foreman_ansible/job_templates/module_action_-_ansible_default.erb
|
227
223
|
- app/views/foreman_ansible/job_templates/package_action_-_ansible_default.erb
|
228
224
|
- app/views/foreman_ansible/job_templates/power_action_-_ansible_default.erb
|
@@ -350,7 +346,6 @@ files:
|
|
350
346
|
- test/unit/services/ansible_report_importer_test.rb
|
351
347
|
- test/unit/services/ansible_variables_importer_test.rb
|
352
348
|
- test/unit/services/api_roles_importer_test.rb
|
353
|
-
- test/unit/services/insights_plan_runner_test.rb
|
354
349
|
- test/unit/services/inventory_creator_test.rb
|
355
350
|
- test/unit/services/override_resolver_test.rb
|
356
351
|
- test/unit/services/roles_importer_test.rb
|
@@ -500,7 +495,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
500
495
|
- !ruby/object:Gem::Version
|
501
496
|
version: '0'
|
502
497
|
requirements: []
|
503
|
-
rubygems_version: 3.2.
|
498
|
+
rubygems_version: 3.2.33
|
504
499
|
signing_key:
|
505
500
|
specification_version: 4
|
506
501
|
summary: Ansible integration with Foreman (theforeman.org)
|
@@ -546,7 +541,6 @@ test_files:
|
|
546
541
|
- test/unit/services/ansible_report_importer_test.rb
|
547
542
|
- test/unit/services/ansible_variables_importer_test.rb
|
548
543
|
- test/unit/services/api_roles_importer_test.rb
|
549
|
-
- test/unit/services/insights_plan_runner_test.rb
|
550
544
|
- test/unit/services/inventory_creator_test.rb
|
551
545
|
- test/unit/services/override_resolver_test.rb
|
552
546
|
- test/unit/services/roles_importer_test.rb
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ForemanAnsible
|
4
|
-
# A class that builds custom notificaton for REX job if it's insights
|
5
|
-
# remediation feature
|
6
|
-
class InsightsNotificationBuilder < ::UINotifications::RemoteExecutionJobs::BaseJobFinish
|
7
|
-
def deliver!
|
8
|
-
::Notification.create!(
|
9
|
-
:audience => Notification::AUDIENCE_USER,
|
10
|
-
:notification_blueprint => blueprint,
|
11
|
-
:initiator => initiator,
|
12
|
-
:message => message,
|
13
|
-
:subject => subject,
|
14
|
-
:actions => {
|
15
|
-
:links => links
|
16
|
-
}
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
def blueprint
|
21
|
-
name = 'insights_remediation_successful'
|
22
|
-
@blueprint ||= NotificationBlueprint.unscoped.find_by(:name => name)
|
23
|
-
end
|
24
|
-
|
25
|
-
def hosts_count
|
26
|
-
@hosts_count ||= subject.template_invocations_hosts.size
|
27
|
-
end
|
28
|
-
|
29
|
-
def message
|
30
|
-
UINotifications::StringParser.new(blueprint.message,
|
31
|
-
:hosts_count => hosts_count)
|
32
|
-
end
|
33
|
-
|
34
|
-
def links
|
35
|
-
job_links + insights_links
|
36
|
-
end
|
37
|
-
|
38
|
-
def insights_links
|
39
|
-
pattern_template = subject.pattern_template_invocations.first
|
40
|
-
plan_id = pattern_template.input_values.
|
41
|
-
joins(:template_input).
|
42
|
-
where('template_inputs.name' => 'plan_id').
|
43
|
-
first.try(:value)
|
44
|
-
return [] if plan_id.nil?
|
45
|
-
|
46
|
-
[
|
47
|
-
{
|
48
|
-
:href => "/redhat_access/insights/planner/#{plan_id}",
|
49
|
-
:title => _('Remediation Plan')
|
50
|
-
}
|
51
|
-
]
|
52
|
-
end
|
53
|
-
|
54
|
-
def job_links
|
55
|
-
UINotifications::URLResolver.new(
|
56
|
-
subject,
|
57
|
-
:links => [{
|
58
|
-
:path_method => :job_invocation_path,
|
59
|
-
:title => _('Job Details')
|
60
|
-
}]
|
61
|
-
).actions[:links]
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if defined?(RedhatAccess)
|
4
|
-
module ForemanAnsible
|
5
|
-
# Fetch information about a plan from RH Insights and run it
|
6
|
-
class InsightsPlanRunner
|
7
|
-
include RedhatAccess::Telemetry::LookUps
|
8
|
-
|
9
|
-
def initialize(organization, plan_id)
|
10
|
-
@organization = organization
|
11
|
-
@plan_id = plan_id
|
12
|
-
end
|
13
|
-
|
14
|
-
def run_playbook
|
15
|
-
rules = playbook
|
16
|
-
hostname_rules_relation = hostname_rules(rules)
|
17
|
-
hosts = hostname_rules_relation.keys.map do |hostname|
|
18
|
-
Host::Managed.find_by(:name => hostname)
|
19
|
-
end
|
20
|
-
|
21
|
-
composer = JobInvocationComposer.for_feature(
|
22
|
-
:ansible_run_insights_plan,
|
23
|
-
hosts,
|
24
|
-
:organization_id => @organization.id, :plan_id => @plan_id
|
25
|
-
)
|
26
|
-
composer.save
|
27
|
-
composer.trigger
|
28
|
-
end
|
29
|
-
|
30
|
-
# Fetches the playbook from the Red Hat Insights API
|
31
|
-
def playbook
|
32
|
-
resource = RestClient::Resource.new(
|
33
|
-
"#{insights_api_host}/r/insights/"\
|
34
|
-
"v3/maintenance/#{@plan_id}/playbook",
|
35
|
-
get_ssl_options_for_org(@organization, nil).\
|
36
|
-
merge(:proxy => get_portal_http_proxy)
|
37
|
-
)
|
38
|
-
@raw_playbook = resource.get.body
|
39
|
-
YAML.safe_load(@raw_playbook)
|
40
|
-
end
|
41
|
-
|
42
|
-
# To parse the disclaimer we iterate over the first lines of the
|
43
|
-
# playbook (all comments) until we get to a line that looks like
|
44
|
-
# "Generated by Red Hat Insights on..."
|
45
|
-
def parse_disclaimer(playbook = @raw_playbook)
|
46
|
-
return '' if playbook.blank?
|
47
|
-
disclaimer = []
|
48
|
-
playbook.split("\n").each do |line|
|
49
|
-
next if line == '---'
|
50
|
-
break unless line[0] == '#'
|
51
|
-
disclaimer << line
|
52
|
-
break if /Generated by Red Hat Insights on/ =~ line
|
53
|
-
end
|
54
|
-
disclaimer.join("\n")
|
55
|
-
end
|
56
|
-
|
57
|
-
# This method creates a hash like this:
|
58
|
-
# {
|
59
|
-
# hostname1 => [rule1,rule2,rule3],
|
60
|
-
# hostname2 => [rule1,rule3],
|
61
|
-
# }
|
62
|
-
#
|
63
|
-
# Rules are distinguished by name and saved without the 'hosts' field
|
64
|
-
# as it's irrelevant in the Foreman REX context ('hosts: all' is used
|
65
|
-
# so that all=job invocation targets)
|
66
|
-
def rules_to_hash(rules)
|
67
|
-
result = {}
|
68
|
-
rules.map do |rule|
|
69
|
-
rule['hosts'] = 'all'
|
70
|
-
result[rule['name']] = rule
|
71
|
-
end
|
72
|
-
result
|
73
|
-
end
|
74
|
-
|
75
|
-
def hostname_rules(rules)
|
76
|
-
result = Hash.new { |h, k| h[k] = [] }
|
77
|
-
rules.each do |rule|
|
78
|
-
rule['hosts'].split(',').each do |host|
|
79
|
-
result[host] << rule['name']
|
80
|
-
end
|
81
|
-
end
|
82
|
-
result
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ForemanAnsible
|
4
|
-
# Macro to fetch RH Insights plan playbook
|
5
|
-
module RendererMethods
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
extend ApipieDSL::Module
|
8
|
-
|
9
|
-
apipie :class, 'Macros related to Ansible playbooks' do
|
10
|
-
name 'Ansible'
|
11
|
-
sections only: %w[all jobs]
|
12
|
-
end
|
13
|
-
|
14
|
-
apipie :method, 'Returns Insights maintenance plan for host' do
|
15
|
-
required :plan_id, String, desc: 'The playbook for the rule coming from insights'
|
16
|
-
optional :organization_id, Integer, desc: 'The Foreman organization associated with the Insights account', default: 'Current organization ID'
|
17
|
-
returns String, desc: 'Insights maintenance plan for host'
|
18
|
-
end
|
19
|
-
def insights_remediation(plan_id, organization_id = Organization.current.id)
|
20
|
-
return "$INSIGHTS_REMEDIATION[#{plan_id}, #{organization_id}]" if preview?
|
21
|
-
|
22
|
-
cached("insights_#{plan_id}_#{organization_id}") do
|
23
|
-
Rails.logger.debug 'cache miss for insights plan fetching'
|
24
|
-
insights_plan = ForemanAnsible::InsightsPlanRunner.new(
|
25
|
-
Organization.find(organization_id),
|
26
|
-
plan_id
|
27
|
-
)
|
28
|
-
rules = insights_plan.playbook
|
29
|
-
disclaimer = insights_plan.parse_disclaimer
|
30
|
-
hostname_rules_relation = insights_plan.hostname_rules(rules)
|
31
|
-
global_rules = insights_plan.rules_to_hash(rules)
|
32
|
-
host_playbooks = individual_host_playbooks(hostname_rules_relation,
|
33
|
-
global_rules)
|
34
|
-
"#{disclaimer}\n#{host_playbooks.to_yaml}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def individual_host_playbooks(hostname_rules_relation, global_rules)
|
41
|
-
hostname_rules_relation[@host.name].reduce([]) do |acc, cur|
|
42
|
-
acc << global_rules[cur]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%#
|
2
|
-
kind: job_template
|
3
|
-
name: Ansible - Run insights maintenance plan
|
4
|
-
job_category: Ansible Playbook
|
5
|
-
description_format: 'Insights maintenance plan for host'
|
6
|
-
feature: ansible_run_insights_plan
|
7
|
-
template_inputs:
|
8
|
-
- name: plan_id
|
9
|
-
description: The playbook for the rule coming from insights.
|
10
|
-
input_type: user
|
11
|
-
required: true
|
12
|
-
- name: organization_id
|
13
|
-
description: The Foreman organization associated with the Insights account
|
14
|
-
input_type: user
|
15
|
-
required: true
|
16
|
-
provider_type: Ansible
|
17
|
-
%>
|
18
|
-
|
19
|
-
<%= insights_remediation(input(:plan_id), input(:organization_id)) %>
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_plugin_helper'
|
4
|
-
|
5
|
-
if defined? RedhatAccess
|
6
|
-
module ForemanAnsible
|
7
|
-
# Tests for the RH Insights plan runner. Mostly about checking whether
|
8
|
-
# the playbook can be parsed properly
|
9
|
-
class InsightsPlanRunnerTest < ActiveSupport::TestCase
|
10
|
-
test 'disclaimer is saved as raw_playbook' do
|
11
|
-
disclaimer = <<-DISCLAIMER.strip_heredoc.strip
|
12
|
-
# Red Hat Insights has recommended one or more actions for you, a system administrator, to review and if you
|
13
|
-
# deem appropriate, deploy on your systems running Red Hat software. Based on the analysis, we have automatically
|
14
|
-
# generated an Ansible Playbook for you. Please review and test the recommended actions and the Playbook as
|
15
|
-
# they may contain configuration changes, updates, reboots and/or other changes to your systems. Red Hat is not
|
16
|
-
# responsible for any adverse outcomes related to these recommendations or Playbooks.
|
17
|
-
#
|
18
|
-
# Addresses maintenance plan 38439429 (demo)
|
19
|
-
# https://access.redhat.com/insights/planner/438294928
|
20
|
-
# Generated by Red Hat Insights on Wed, 18 Apr 2018 07:54:18 GMT
|
21
|
-
DISCLAIMER
|
22
|
-
|
23
|
-
playbook = File.read(ansible_fixture_file('insights_playbook.yaml'))
|
24
|
-
planner = ::ForemanAnsible::InsightsPlanRunner.new(
|
25
|
-
FactoryBot.build(:organization), rand
|
26
|
-
)
|
27
|
-
assert_empty planner.parse_disclaimer
|
28
|
-
planner.expects(:insights_api_host).returns('')
|
29
|
-
planner.expects(:get_ssl_options_for_org).returns(nil)
|
30
|
-
RestClient::Resource.any_instance.expects(:get).returns(
|
31
|
-
OpenStruct.new(:body => playbook)
|
32
|
-
)
|
33
|
-
planner.playbook
|
34
|
-
assert_equal disclaimer, planner.parse_disclaimer
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|