foreman_ansible 10.4.0 → 10.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c30c3eac6e4a49a8d43c6a654d84b672ef9fa58bbacb8fe2044cc74f33b5a28
4
- data.tar.gz: 8084c75afc69d788093952a8988e3ff883f3726779a94f1de5016c1b857d7435
3
+ metadata.gz: 5d5fe936def15be1cc84456bb6d1fa5df9a5a895c2aea3da888908dbaa59c6fb
4
+ data.tar.gz: 7cb834bfefdcfc73743d06c06e70b61965bd49d3b5aa263963ec7998d4ab70dc
5
5
  SHA512:
6
- metadata.gz: e541db04ed8d5bb3ed65b8239a06366efbda044d57263e4e507534c61a89d566e1270b67593a5c33d423abf13bc7896f76208aa81efc36f58382bd972d40cd7f
7
- data.tar.gz: 5df022f589352f580358303a3172f8062e476884607e1dafd21ee8f140646e106a93419c018b896df55b4bc4cac102374bb92bd3c46e8dc9e42998c52c2bb26e
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.0'
7
+ VERSION = '10.4.2'
8
8
  end
data/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "test": "test"
8
8
  },
9
9
  "peerDependencies": {
10
- "@theforeman/vendor": ">= 8.16.0"
10
+ "@theforeman/vendor": "^10.0"
11
11
  },
12
12
  "dependencies": {
13
13
  "react-json-tree": "^0.11.0"
@@ -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
@@ -86,12 +86,16 @@ const validateRegexp = (variable, value) => {
86
86
  };
87
87
 
88
88
  const validateList = (variable, value) => {
89
- if (variable.validatorRule.split(',').find(item => item.trim() === value)) {
89
+ let { validatorRule } = variable;
90
+ if (typeof validatorRule !== 'string') {
91
+ validatorRule = validatorRule.toString();
92
+ }
93
+ if (validatorRule.split(',').find(item => item.trim() === value)) {
90
94
  return validationSuccess;
91
95
  }
92
96
  return {
93
97
  key: 'error',
94
- msg: sprintf(__('Invalid, expected one of: %s'), variable.validatorRule),
98
+ msg: sprintf(__('Invalid, expected one of: %s'), validatorRule),
95
99
  };
96
100
  };
97
101
 
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.0
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-12 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
@@ -42,36 +42,30 @@ dependencies:
42
42
  name: foreman_remote_execution
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '8.0'
48
- - - "<"
45
+ - - "~>"
49
46
  - !ruby/object:Gem::Version
50
- version: '10'
47
+ version: '8.2'
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: '8.0'
58
- - - "<"
52
+ - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '10'
54
+ version: '8.2'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: foreman-tasks
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '7.0'
61
+ version: '7.1'
68
62
  type: :runtime
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: '7.0'
68
+ version: '7.1'
75
69
  description: Ansible integration with Foreman
76
70
  email:
77
71
  - elobatocs@gmail.com
@@ -204,6 +198,7 @@ files:
204
198
  - app/views/foreman_ansible/job_templates/run_playbook-ansible_default.erb
205
199
  - app/views/foreman_ansible/job_templates/service_action_-_ansible_default.erb
206
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
207
202
  - app/views/ui_ansible_roles/index.json.rabl
208
203
  - app/views/ui_ansible_roles/main.json.rabl
209
204
  - app/views/ui_ansible_roles/show.json.rabl
@@ -484,10 +479,10 @@ test_files:
484
479
  - test/foreman_ansible/helpers/ansible_roles_helper_test.rb
485
480
  - test/functional/ansible_roles_controller_test.rb
486
481
  - test/functional/ansible_variables_controller_test.rb
487
- - test/functional/api/v2/ansible_inventories_controller_test.rb
488
482
  - test/functional/api/v2/ansible_playbooks_controller_test.rb
489
483
  - test/functional/api/v2/ansible_roles_controller_test.rb
490
484
  - test/functional/api/v2/ansible_variables_controller_test.rb
485
+ - test/functional/api/v2/ansible_inventories_controller_test.rb
491
486
  - test/functional/api/v2/hostgroups_controller_test.rb
492
487
  - test/functional/api/v2/hosts_controller_test.rb
493
488
  - test/functional/hosts_controller_test.rb