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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6036f9a1d90705a4459c56093084b63c953a7c657a125f4f04ca878fb9bc7552
4
- data.tar.gz: 5354e5227c4eccf6fcee0f721b3e03a10d0d119354d3dc3b2aa742ad44105023
3
+ metadata.gz: 5d5fe936def15be1cc84456bb6d1fa5df9a5a895c2aea3da888908dbaa59c6fb
4
+ data.tar.gz: 7cb834bfefdcfc73743d06c06e70b61965bd49d3b5aa263963ec7998d4ab70dc
5
5
  SHA512:
6
- metadata.gz: a29b28a5c665e8af6f52b9b5b2e7ff94f88f87912795ef54c5eedbb7347c666796a42c09456bcd6b50ed30e1d17a1e28f25ab23929fad6b34a4b51ceb87f5131
7
- data.tar.gz: 482d9f6ee4f9c1367a45d87cd4158c29ef88ca2860b6183cdf159123a5a9cf88c7bcca18549b7d448cfff9a5094a3eda24f782f7cd1339e0d0d1fd9abfb1b28c
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
- play_roles = if hostgroup.all_ansible_roles.empty?
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
- assign_jobs = { action: { content: (link_to _('Configure Ansible Job'), "/ansible/hostgroups/#{hostgroup.id}", class: 'la') }, priority: 32 }
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
- actions.push play_roles if User.current.can?(:create_job_invocations)
16
- actions.push assign_jobs if User.current.can?(:view_job_invocations) && User.current.can?(:view_recurring_logics)
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
- feature = RemoteExecutionFeature.feature(:ansible_run_capsule_upgrade)
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: Smart Proxy Upgrade Playbook
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
- tasks:
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: "This playbook cannot be executed on a Foreman server. Use only on a Smart Proxy server."
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
@@ -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.1'
7
+ VERSION = '10.4.2'
8
8
  end
@@ -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 link' do
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 link' do
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.1
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-02-27 00:00:00.000000000 Z
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