foreman_ansible 10.4.1 → 10.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/foreman_ansible/ansible_hostgroups_helper.rb +28 -8
- data/app/helpers/foreman_ansible/smart_proxies_helper.rb +7 -1
- data/app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb +4 -32
- data/app/views/foreman_ansible/job_templates/smart_proxy_upgrade_-_ansible_default.erb +59 -0
- data/lib/foreman_ansible/version.rb +1 -1
- data/test/integration/hostgroup_js_test.rb +4 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d5fe936def15be1cc84456bb6d1fa5df9a5a895c2aea3da888908dbaa59c6fb
|
4
|
+
data.tar.gz: 7cb834bfefdcfc73743d06c06e70b61965bd49d3b5aa263963ec7998d4ab70dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 437ca9c045cb2e07982d4ca9a73913d80a8f155c1d5f5324e29f544554a3defddbf1295ee1093ac5cbbf87f60cb18981be394c26df7466c4b53943f77da99f23
|
7
|
+
data.tar.gz: 5eb239a127d53b9b97b9a7bc2a6145f7bb96af3e8d3cb079b6b6e8d546b48ba441273062258429c8b35cfa3c387e993996e91a9d95a18b8300f8d9eaea1ddb80
|
@@ -4,18 +4,38 @@ module ForemanAnsible
|
|
4
4
|
module AnsibleHostgroupsHelper
|
5
5
|
def ansible_hostgroups_actions(hostgroup)
|
6
6
|
actions = []
|
7
|
-
|
8
|
-
{ action: { content: (link_to _('Run all Ansible roles'), 'javascript:void(0);', disabled: true, title: 'No roles assigned', class: 'disabled'), options: { class: 'disabled' } }, priority: 31 }
|
9
|
-
else
|
10
|
-
{ action: display_link_if_authorized(_('Run all Ansible roles'), hash_for_play_roles_hostgroup_path(id: hostgroup), 'data-no-turbolink': true, title: _('Run all Ansible roles on hosts belonging to this host group')), priority: 31 }
|
11
|
-
end
|
7
|
+
is_hostgroup_empty = hostgroup.all_ansible_roles.empty? || hostgroup.hosts_count.zero?
|
12
8
|
|
13
|
-
|
9
|
+
if User.current.can?(:create_job_invocations)
|
10
|
+
actions << {
|
11
|
+
action: if is_hostgroup_empty
|
12
|
+
disabled_action_link(_('Run all Ansible roles'))
|
13
|
+
else
|
14
|
+
display_link_if_authorized(_('Run all Ansible roles'), hash_for_play_roles_hostgroup_path(id: hostgroup), 'data-no-turbolink': true, title: _('Run all Ansible roles on hosts belonging to this host group'))
|
15
|
+
end,
|
16
|
+
priority: 31
|
17
|
+
}
|
18
|
+
end
|
14
19
|
|
15
|
-
|
16
|
-
|
20
|
+
if User.current.can?(:view_job_invocations) && User.current.can?(:view_recurring_logics)
|
21
|
+
actions << {
|
22
|
+
action: if is_hostgroup_empty
|
23
|
+
disabled_action_link(_('Configure Ansible Job'))
|
24
|
+
else
|
25
|
+
link_to(_('Configure Ansible Job'), "/ansible/hostgroups/#{hostgroup.id}", class: 'la')
|
26
|
+
end,
|
27
|
+
priority: 32
|
28
|
+
}
|
29
|
+
end
|
17
30
|
|
18
31
|
actions
|
19
32
|
end
|
33
|
+
|
34
|
+
def disabled_action_link(text)
|
35
|
+
{
|
36
|
+
content: link_to(text, 'javascript:void(0);', disabled: true, title: _('No roles/hosts assigned'), class: 'disabled'),
|
37
|
+
options: { class: 'disabled' }
|
38
|
+
}
|
39
|
+
end
|
20
40
|
end
|
21
41
|
end
|
@@ -27,7 +27,13 @@ module ForemanAnsible
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def proxy_update_button(proxy)
|
30
|
-
|
30
|
+
name = if Foreman::Plugin.find('foreman_theme_satellite').present?
|
31
|
+
:ansible_run_capsule_upgrade
|
32
|
+
else
|
33
|
+
:ansible_run_smart_proxy_upgrade
|
34
|
+
end
|
35
|
+
|
36
|
+
feature = RemoteExecutionFeature.feature(name)
|
31
37
|
return if feature.nil?
|
32
38
|
|
33
39
|
path = new_job_invocation_path(:host_ids => proxy.infrastructure_host_facets.pluck(:host_id),
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%#
|
2
|
-
name:
|
2
|
+
name: Capsule Upgrade Playbook
|
3
3
|
snippet: false
|
4
4
|
template_inputs:
|
5
5
|
- name: target_version
|
@@ -26,8 +26,8 @@ feature: ansible_run_capsule_upgrade
|
|
26
26
|
- hosts: all
|
27
27
|
vars:
|
28
28
|
target_version: "<%= input('target_version').present? ? input('target_version') : product_short_version %>"
|
29
|
-
<% if plugin_present?('foreman_theme_satellite') -%>
|
30
29
|
tasks:
|
30
|
+
<% if plugin_present?('foreman_theme_satellite') -%>
|
31
31
|
- name: Gather the rpm package facts
|
32
32
|
package_facts:
|
33
33
|
manager: auto
|
@@ -75,35 +75,7 @@ feature: ansible_run_capsule_upgrade
|
|
75
75
|
fail:
|
76
76
|
msg: "Failed! Capsule server upgrade failed. See /var/log/foreman-installer/capsule.log in the Capsule server for more information"
|
77
77
|
<% else -%>
|
78
|
-
|
79
|
-
- name: Gather the rpm package facts
|
80
|
-
package_facts:
|
81
|
-
manager: auto
|
82
|
-
|
83
|
-
- name: Fail if the target server is a Foreman server
|
78
|
+
- name: Fail if foreman_theme_satellite is missing
|
84
79
|
fail:
|
85
|
-
msg: "
|
86
|
-
when: "'foreman' in ansible_facts.packages"
|
87
|
-
|
88
|
-
- name: Install foreman release gpg key
|
89
|
-
rpm_key:
|
90
|
-
state: present
|
91
|
-
key: http://yum.theforeman.org/releases/{{ target_version }}/RPM-GPG-KEY-foreman
|
92
|
-
when: target_version != "nightly"
|
93
|
-
|
94
|
-
- name: Update foreman repositories
|
95
|
-
package:
|
96
|
-
name: https://yum.theforeman.org/releases/{{ target_version }}/el{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/foreman-release.rpm
|
97
|
-
state: installed
|
98
|
-
|
99
|
-
- name: Clean yum metadata
|
100
|
-
command: yum clean all
|
101
|
-
|
102
|
-
- name: Update all packages
|
103
|
-
package:
|
104
|
-
name: '*'
|
105
|
-
state: latest
|
106
|
-
|
107
|
-
- name: Run the installer
|
108
|
-
shell: foreman-installer
|
80
|
+
msg: "Failed! The plugin foreman_theme_satellite is not present. This playbook is only for use with Satellite."
|
109
81
|
<% end -%>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<%#
|
2
|
+
name: Smart Proxy Upgrade Playbook
|
3
|
+
snippet: false
|
4
|
+
template_inputs:
|
5
|
+
- name: target_version
|
6
|
+
required: false
|
7
|
+
input_type: user
|
8
|
+
advanced: false
|
9
|
+
value_type: plain
|
10
|
+
hidden_value: false
|
11
|
+
- name: whitelist_options
|
12
|
+
required: false
|
13
|
+
input_type: user
|
14
|
+
advanced: false
|
15
|
+
value_type: plain
|
16
|
+
hidden_value: false
|
17
|
+
model: JobTemplate
|
18
|
+
job_category: Maintenance Operations
|
19
|
+
description_format: "%{template_name}"
|
20
|
+
provider_type: Ansible
|
21
|
+
kind: job_template
|
22
|
+
feature: ansible_run_smart_proxy_upgrade
|
23
|
+
%>
|
24
|
+
|
25
|
+
---
|
26
|
+
- hosts: all
|
27
|
+
vars:
|
28
|
+
target_version: "<%= input('target_version').present? ? input('target_version') : product_short_version %>"
|
29
|
+
tasks:
|
30
|
+
- name: Gather the rpm package facts
|
31
|
+
package_facts:
|
32
|
+
manager: auto
|
33
|
+
|
34
|
+
- name: Fail if the target server is a Foreman server
|
35
|
+
fail:
|
36
|
+
msg: "This playbook cannot be executed on a Foreman server. Use only on a Smart Proxy server."
|
37
|
+
when: "'foreman' in ansible_facts.packages"
|
38
|
+
|
39
|
+
- name: Install foreman release gpg key
|
40
|
+
rpm_key:
|
41
|
+
state: present
|
42
|
+
key: http://yum.theforeman.org/releases/{{ target_version }}/RPM-GPG-KEY-foreman
|
43
|
+
when: target_version != "nightly"
|
44
|
+
|
45
|
+
- name: Update foreman repositories
|
46
|
+
package:
|
47
|
+
name: https://yum.theforeman.org/releases/{{ target_version }}/el{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/foreman-release.rpm
|
48
|
+
state: installed
|
49
|
+
|
50
|
+
- name: Clean yum metadata
|
51
|
+
command: yum clean all
|
52
|
+
|
53
|
+
- name: Update all packages
|
54
|
+
package:
|
55
|
+
name: '*'
|
56
|
+
state: latest
|
57
|
+
|
58
|
+
- name: Run the installer
|
59
|
+
shell: foreman-installer
|
@@ -10,21 +10,23 @@ class HostgroupJsTest < IntegrationTestWithJavascript
|
|
10
10
|
FactoryBot.create(:host, :hostgroup_id => hostgroup_with_roles.id)
|
11
11
|
end
|
12
12
|
|
13
|
-
test 'hostgroup without roles should have disabled
|
13
|
+
test 'hostgroup without roles should have disabled links' do
|
14
14
|
visit hostgroups_path(search: hostgroup.name)
|
15
15
|
|
16
16
|
first_row = page.find('table > tbody > tr:nth-child(1)')
|
17
17
|
first_row.find('td:nth-child(4) > div > a').click
|
18
18
|
|
19
19
|
assert_includes first(:link, 'Run all Ansible roles')[:class], 'disabled'
|
20
|
+
assert_includes first(:link, 'Configure Ansible Job')[:class], 'disabled'
|
20
21
|
end
|
21
22
|
|
22
|
-
test 'hostgroup with roles should have clickable
|
23
|
+
test 'hostgroup with roles should have clickable links' do
|
23
24
|
visit hostgroups_path(search: hostgroup_with_roles.name)
|
24
25
|
|
25
26
|
first_row = page.find('table > tbody > tr:nth-child(1)')
|
26
27
|
first_row.find('td:nth-child(4) > div > a').click
|
27
28
|
|
28
29
|
assert_not first(:link, 'Run all Ansible roles')[:class].include?('disabled')
|
30
|
+
assert_not first(:link, 'Configure Ansible Job')[:class].include?('disabled')
|
29
31
|
end
|
30
32
|
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.2
|
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-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_list
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- app/views/foreman_ansible/job_templates/run_playbook-ansible_default.erb
|
199
199
|
- app/views/foreman_ansible/job_templates/service_action_-_ansible_default.erb
|
200
200
|
- app/views/foreman_ansible/job_templates/service_action_-_enable_web_console.erb
|
201
|
+
- app/views/foreman_ansible/job_templates/smart_proxy_upgrade_-_ansible_default.erb
|
201
202
|
- app/views/ui_ansible_roles/index.json.rabl
|
202
203
|
- app/views/ui_ansible_roles/main.json.rabl
|
203
204
|
- app/views/ui_ansible_roles/show.json.rabl
|
@@ -492,9 +493,9 @@ test_files:
|
|
492
493
|
- test/test_plugin_helper.rb
|
493
494
|
- test/unit/ansible_role_test.rb
|
494
495
|
- test/unit/ansible_variable_test.rb
|
495
|
-
- test/unit/concerns/config_reports_extensions_test.rb
|
496
496
|
- test/unit/concerns/host_managed_extensions_test.rb
|
497
497
|
- test/unit/concerns/hostgroup_extensions_test.rb
|
498
|
+
- test/unit/concerns/config_reports_extensions_test.rb
|
498
499
|
- test/unit/helpers/ansible_reports_helper_test.rb
|
499
500
|
- test/unit/host_ansible_role_test.rb
|
500
501
|
- test/unit/hostgroup_ansible_role_test.rb
|