foreman_ansible 10.3.0 → 10.4.1

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: 3b1b699102370b4e5a97d04d193bd0fcea93579d921cc0e85765e026b367b573
4
- data.tar.gz: 81815947622a3207f02566dd22a90fa812c3c13084344e039d5c398f8ed3d91b
3
+ metadata.gz: 6036f9a1d90705a4459c56093084b63c953a7c657a125f4f04ca878fb9bc7552
4
+ data.tar.gz: 5354e5227c4eccf6fcee0f721b3e03a10d0d119354d3dc3b2aa742ad44105023
5
5
  SHA512:
6
- metadata.gz: 3231ccc8fd6ef3f4b7705ea63cacf42cecc35f86332a79dd0d44dafbe2a700e0eb6e81b97a8185c1c3cae7c27657cbe8ee5c998b1f6c008d0905ae4c76d53d01
7
- data.tar.gz: 7ea76ec8df5ebabc52f32f6edcde10892f2578dc74bf452fcaa64e41a0688e1c9b5c4091cbc7cbb6275f10d2e3e4bbe4faf8118be47be6feb582e629e7a28ebf
6
+ metadata.gz: a29b28a5c665e8af6f52b9b5b2e7ff94f88f87912795ef54c5eedbb7347c666796a42c09456bcd6b50ed30e1d17a1e28f25ab23929fad6b34a4b51ceb87f5131
7
+ data.tar.gz: 482d9f6ee4f9c1367a45d87cd4158c29ef88ca2860b6183cdf159123a5a9cf88c7bcca18549b7d448cfff9a5094a3eda24f782f7cd1339e0d0d1fd9abfb1b28c
@@ -8,12 +8,14 @@ module Types
8
8
  argument :match, String, required: false
9
9
  end
10
10
 
11
- field :meta, ::Types::Meta, resolve: (proc do |object|
11
+ field :meta, ::Types::Meta
12
+
13
+ def meta
12
14
  {
13
15
  :can_edit => ::User.current.can?(object.ansible_variable.permission_name(:edit), object.ansible_variable),
14
16
  :can_destroy => ::User.current.can?(object.ansible_variable.permission_name(:destroy), object.ansible_variable)
15
17
  }
16
- end)
18
+ end
17
19
 
18
20
  def lookup_values(match: nil)
19
21
  return CollectionLoader.for(object.ansible_variable.class, :lookup_values).load(object.ansible_variable) unless match
@@ -3,13 +3,19 @@
3
3
  module ForemanAnsible
4
4
  module AnsibleHostgroupsHelper
5
5
  def ansible_hostgroups_actions(hostgroup)
6
+ actions = []
6
7
  play_roles = if hostgroup.all_ansible_roles.empty?
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 }
8
9
  else
9
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 }
10
11
  end
11
12
 
12
- [play_roles] if User.current.can?(:create_job_invocations)
13
+ assign_jobs = { action: { content: (link_to _('Configure Ansible Job'), "/ansible/hostgroups/#{hostgroup.id}", class: 'la') }, priority: 32 }
14
+
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)
17
+
18
+ actions
13
19
  end
14
20
  end
15
21
  end
@@ -27,7 +27,10 @@ module ForemanAnsible
27
27
 
28
28
  def ansible_module_message(log)
29
29
  msg_json = parsed_message_json(log)
30
- module_action = msg_json['module']
30
+ return _("Execution error: #{msg_json['msg']}") if msg_json['failed'].present?
31
+ return msg_json['censored'] if msg_json['censored'].present?
32
+
33
+ module_action = msg_json.fetch('module', '').delete_prefix('ansible.builtin.').delete_prefix('ansible.legacy.')
31
34
  case module_action
32
35
  when 'package'
33
36
  msg_json['results'].empty? ? msg_json['msg'] : msg_json['results']
@@ -1,5 +1,5 @@
1
1
  class FixAnsibleSettingCategoryToDsl < ActiveRecord::Migration[6.0]
2
2
  def up
3
- Setting.where(category: 'Setting::Ansible').update_all(category: 'Setting')
3
+ Setting.where(category: 'Setting::Ansible').update_all(category: 'Setting') if column_exists?(:settings, :category)
4
4
  end
5
5
  end
@@ -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.3.0'
7
+ VERSION = '10.4.1'
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"
@@ -40,4 +40,43 @@ ANSIBLELOG
40
40
  end
41
41
  assert_equal expected_outputs, actual_outputs
42
42
  end
43
+
44
+ test 'accepting an almost empty message' do
45
+ log_value = <<-ANSIBLELOG.strip_heredoc
46
+ {"changed": true, "failed": false, "module": "copy"}
47
+ ANSIBLELOG
48
+ message = FactoryBot.build(:message, value: log_value)
49
+ log = FactoryBot.build(:log)
50
+ log.message = message
51
+ assert_match(
52
+ /Copy/,
53
+ ansible_module_message(log).to_s
54
+ )
55
+ end
56
+
57
+ test 'FQCN module message extraction' do
58
+ log_value = <<-ANSIBLELOG.strip_heredoc
59
+ {"msg": "Nothing to do", "changed": false, "results": [], "rc": 0, "invocation": {"module_args": {"name": ["openssh"], "state": "present", "allow_downgrade": false, "autoremove": false, "bugfix": false, "disable_gpg_check": false, "disable_plugin": [], "disablerepo": [], "download_only": false, "enable_plugin": [], "enablerepo": [], "exclude": [], "installroot": "/", "install_repoquery": true, "install_weak_deps": true, "security": false, "skip_broken": false, "update_cache": false, "update_only": false, "validate_certs": true, "lock_timeout": 30, "conf_file": null, "disable_excludes": null, "download_dir": null, "list": null, "releasever": null}}, "_ansible_no_log": false, "failed": false, "module": "ansible.builtin.package"}
60
+ ANSIBLELOG
61
+ message = FactoryBot.build(:message, value: log_value)
62
+ log = FactoryBot.build(:log)
63
+ log.message = message
64
+ assert_match(
65
+ /Nothing to do/,
66
+ ansible_module_message(log).to_s
67
+ )
68
+ end
69
+
70
+ test 'accepting a censored message' do
71
+ log_value = <<-ANSIBLELOG.strip_heredoc
72
+ {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": true, "failed": false, "module": "copy"}
73
+ ANSIBLELOG
74
+ message = FactoryBot.build(:message, value: log_value)
75
+ log = FactoryBot.build(:log)
76
+ log.message = message
77
+ assert_match(
78
+ /output has been hidden/,
79
+ ansible_module_message(log).to_s
80
+ )
81
+ end
43
82
  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
 
@@ -8,4 +8,9 @@ fragment CurrentUserAttributes on User {
8
8
  name
9
9
  }
10
10
  }
11
+ usergroups {
12
+ nodes {
13
+ admin
14
+ }
15
+ }
11
16
  }
@@ -11,7 +11,10 @@ export const permissionCheck = (user, permissionsRequired) => {
11
11
  );
12
12
  }
13
13
 
14
- if (user.admin) {
14
+ if (
15
+ user.admin ||
16
+ user.usergroups.nodes.find(usergroup => usergroup.admin === true)
17
+ ) {
15
18
  return { allowed: true };
16
19
  }
17
20
 
@@ -71,6 +71,9 @@ export const userFactory = (login, permissions = []) => ({
71
71
  permissions: {
72
72
  nodes: permissions,
73
73
  },
74
+ usergroups: {
75
+ nodes: [],
76
+ },
74
77
  });
75
78
 
76
79
  export const admin = {
@@ -81,6 +84,9 @@ export const admin = {
81
84
  permissions: {
82
85
  nodes: [],
83
86
  },
87
+ usergroups: {
88
+ nodes: [],
89
+ },
84
90
  };
85
91
 
86
92
  export const intruder = userFactory('intruder', [
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.3.0
4
+ version: 10.4.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: 2023-01-26 00:00:00.000000000 Z
11
+ date: 2023-02-27 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
@@ -484,10 +478,10 @@ test_files:
484
478
  - test/foreman_ansible/helpers/ansible_roles_helper_test.rb
485
479
  - test/functional/ansible_roles_controller_test.rb
486
480
  - test/functional/ansible_variables_controller_test.rb
487
- - test/functional/api/v2/ansible_inventories_controller_test.rb
488
481
  - test/functional/api/v2/ansible_playbooks_controller_test.rb
489
482
  - test/functional/api/v2/ansible_roles_controller_test.rb
490
483
  - test/functional/api/v2/ansible_variables_controller_test.rb
484
+ - test/functional/api/v2/ansible_inventories_controller_test.rb
491
485
  - test/functional/api/v2/hostgroups_controller_test.rb
492
486
  - test/functional/api/v2/hosts_controller_test.rb
493
487
  - test/functional/hosts_controller_test.rb
@@ -498,9 +492,9 @@ test_files:
498
492
  - test/test_plugin_helper.rb
499
493
  - test/unit/ansible_role_test.rb
500
494
  - test/unit/ansible_variable_test.rb
495
+ - test/unit/concerns/config_reports_extensions_test.rb
501
496
  - test/unit/concerns/host_managed_extensions_test.rb
502
497
  - test/unit/concerns/hostgroup_extensions_test.rb
503
- - test/unit/concerns/config_reports_extensions_test.rb
504
498
  - test/unit/helpers/ansible_reports_helper_test.rb
505
499
  - test/unit/host_ansible_role_test.rb
506
500
  - test/unit/hostgroup_ansible_role_test.rb