foreman_ansible 7.1.1 → 7.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/app/views/foreman_ansible/job_templates/ansible_roles_-_install_from_git.erb +4 -1
  3. data/lib/foreman_ansible/register.rb.orig +257 -0
  4. data/lib/foreman_ansible/remote_execution.rb +0 -6
  5. data/lib/foreman_ansible/version.rb +1 -1
  6. data/locale/ca/foreman_ansible.edit.po +0 -0
  7. data/locale/ca/foreman_ansible.po.time_stamp +0 -0
  8. data/locale/cs_CZ/foreman_ansible.edit.po +0 -0
  9. data/locale/cs_CZ/foreman_ansible.po.time_stamp +0 -0
  10. data/locale/de/foreman_ansible.edit.po +0 -0
  11. data/locale/de/foreman_ansible.po.time_stamp +0 -0
  12. data/locale/en/foreman_ansible.edit.po +0 -0
  13. data/locale/en/foreman_ansible.po.time_stamp +0 -0
  14. data/locale/en_GB/foreman_ansible.edit.po +0 -0
  15. data/locale/en_GB/foreman_ansible.po.time_stamp +0 -0
  16. data/locale/es/foreman_ansible.edit.po +0 -0
  17. data/locale/es/foreman_ansible.po.time_stamp +0 -0
  18. data/locale/fr/foreman_ansible.edit.po +0 -0
  19. data/locale/fr/foreman_ansible.po.time_stamp +0 -0
  20. data/locale/gl/foreman_ansible.edit.po +0 -0
  21. data/locale/gl/foreman_ansible.po.time_stamp +0 -0
  22. data/locale/it/foreman_ansible.edit.po +0 -0
  23. data/locale/it/foreman_ansible.po.time_stamp +0 -0
  24. data/locale/ja/foreman_ansible.edit.po +0 -0
  25. data/locale/ja/foreman_ansible.po.time_stamp +0 -0
  26. data/locale/ko/foreman_ansible.edit.po +0 -0
  27. data/locale/ko/foreman_ansible.po.time_stamp +0 -0
  28. data/locale/nl_NL/foreman_ansible.edit.po +0 -0
  29. data/locale/nl_NL/foreman_ansible.po.time_stamp +0 -0
  30. data/locale/pl/foreman_ansible.edit.po +0 -0
  31. data/locale/pl/foreman_ansible.po.time_stamp +0 -0
  32. data/locale/pt_BR/foreman_ansible.edit.po +0 -0
  33. data/locale/pt_BR/foreman_ansible.po.time_stamp +0 -0
  34. data/locale/ru/foreman_ansible.edit.po +0 -0
  35. data/locale/ru/foreman_ansible.po.time_stamp +0 -0
  36. data/locale/sv_SE/foreman_ansible.edit.po +0 -0
  37. data/locale/sv_SE/foreman_ansible.po.time_stamp +0 -0
  38. data/locale/zh_CN/foreman_ansible.edit.po +0 -0
  39. data/locale/zh_CN/foreman_ansible.po.time_stamp +0 -0
  40. data/locale/zh_TW/foreman_ansible.edit.po +0 -0
  41. data/locale/zh_TW/foreman_ansible.po.time_stamp +0 -0
  42. data/webpack/components/AnsibleHostDetail/components/JobsTab/PreviousJobsTable.js.orig +0 -0
  43. data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/index.js +2 -1
  44. data/webpack/components/AnsibleHostDetail/components/RolesTab/__test__/EditRoles.test.js +2 -1
  45. data/webpack/components/AnsibleHostDetail/components/RolesTab/__test__/RolesTab.test.js +3 -1
  46. data/webpack/components/AnsibleHostDetail/components/RolesTab/index.js +26 -2
  47. data/webpack/components/withLoading.js +7 -12
  48. data/webpack/testHelper.js +12 -3
  49. metadata +35 -35
  50. data/app/views/foreman_ansible/job_templates/configure_cloud_connector_-_ansible_default.erb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99abca0391222ea405dd6639b8556b21df4a139d159d3e949933c2bf59e13eaa
4
- data.tar.gz: 5cbd6af1574f4f9479f8900ff5077badd0d542d37008206e3512b0636f748f75
3
+ metadata.gz: 6c2aa2f197db82b4761ba3383644509cd7d1adf1da8d25767020e4e22bd58a59
4
+ data.tar.gz: 3818951fe2e8f8cbc4fd3c4cf4253e86199f4680f3ea6bbc14603403d9f81b18
5
5
  SHA512:
6
- metadata.gz: 163fac3b03b865a0a0b77cb0d67c585fe95f653ad645e27aa4567f35aebae47717edcce32b6deef3bdb238691f02b85f91a7c3dc65229223127de72f3946a8a8
7
- data.tar.gz: 8a60d45f87f059e75b27b3c2d5f9a2fad077269b8521c1b0e740bd42c81eb2a174e6a8b146beb1c2319f0fd0a846fd74f5a245e7a269f320a45e2b360e250492
6
+ metadata.gz: c29e747b40b8ec1bdf2056058639ebbe28fd566f474addc51ddd220e7f55f47c9db5ad0c3697f284e32eeb8efabd124bb58257e20c8ef50f7196a29da4ee845a
7
+ data.tar.gz: ab30288f2eb2aed966b93eb6bb7b1cbbcf3f9564bff61d9f1bde0161834f5886adf9c7d2a084494021e4b867b886b3530c78bc069212cf893b49c4d887504dc8
@@ -23,6 +23,9 @@ model: JobTemplate
23
23
  ---
24
24
  - hosts: all
25
25
  tasks:
26
- - command: git clone <%= input('git_repository') %> <%= input('location') %>
26
+ - git:
27
+ repo: "<%= input('git_repository') %>"
28
+ dest: "<%= input('location') %>"
27
29
  register: out
30
+
28
31
  - debug: var=out
@@ -0,0 +1,257 @@
1
+ # frozen_string_literal: true
2
+
3
+ Foreman::Plugin.register :foreman_ansible do
4
+ requires_foreman '>= 3.3'
5
+
6
+ settings do
7
+ category :ansible, N_('Ansible') do
8
+ setting 'ansible_ssh_private_key_file',
9
+ type: :string,
10
+ description: N_('Use this to supply a path to an SSH Private Key '\
11
+ 'that Ansible will use in lieu of a password '\
12
+ 'Override with "ansible_ssh_private_key_file" '\
13
+ 'host parameter'),
14
+ default: '',
15
+ full_name: N_('Private Key Path')
16
+ setting 'ansible_connection',
17
+ type: :string,
18
+ description: N_('Use this connection type by default when running '\
19
+ 'Ansible playbooks. You can override this on hosts by '\
20
+ 'adding a parameter "ansible_connection"'),
21
+ default: 'ssh',
22
+ full_name: N_('Connection type')
23
+ setting 'ansible_winrm_server_cert_validation',
24
+ type: :string,
25
+ description: N_('Enable/disable WinRM server certificate '\
26
+ 'validation when running Ansible playbooks. You can override '\
27
+ 'this on hosts by adding a parameter '\
28
+ '"ansible_winrm_server_cert_validation"'),
29
+ default: 'validate',
30
+ full_name: N_('WinRM cert Validation')
31
+ setting 'ansible_verbosity',
32
+ type: :integer,
33
+ description: N_('Foreman will add this level of verbosity for '\
34
+ 'additional debugging output when running Ansible playbooks.'),
35
+ default: '0',
36
+ full_name: N_('Default verbosity level'),
37
+ value: nil,
38
+ collection: proc {
39
+ { '0' => N_('Disabled'),
40
+ '1' => N_('Level 1 (-v)'),
41
+ '2' => N_('Level 2 (-vv)'),
42
+ '3' => N_('Level 3 (-vvv)'),
43
+ '4' => N_('Level 4 (-vvvv)') }
44
+ }
45
+ setting 'ansible_post_provision_timeout',
46
+ type: :integer,
47
+ description: N_('Timeout (in seconds) to set when Foreman will trigger a '\
48
+ 'play Ansible roles task after a host is fully provisioned. '\
49
+ 'Set this to the maximum time you expect a host to take '\
50
+ 'until it is ready after a reboot.'),
51
+ default: '360',
52
+ full_name: N_('Post-provision timeout')
53
+ setting 'ansible_interval',
54
+ type: :integer,
55
+ description: N_('Timeout (in minutes) when hosts should have reported.'),
56
+ default: '30',
57
+ full_name: N_('Ansible report timeout')
58
+ setting 'ansible_out_of_sync_disabled',
59
+ type: :boolean,
60
+ description: format(N_('Disable host configuration status turning to out of'\
61
+ ' sync for %{cfgmgmt} after report does not arrive within'\
62
+ ' configured interval'), :cfgmgmt => 'Ansible'),
63
+ default: false,
64
+ full_name: format(N_('%{cfgmgmt} out of sync disabled'), :cfgmgmt => 'Ansible')
65
+ setting 'ansible_inventory_template',
66
+ type: :string,
67
+ description: N_('Foreman will use this template to schedule the report '\
68
+ 'with Ansible inventory'),
69
+ default: 'Ansible - Ansible Inventory',
70
+ full_name: N_('Default Ansible inventory report template')
71
+ setting 'ansible_roles_to_ignore',
72
+ type: :array,
73
+ description: N_('Those roles will be excluded when importing roles from smart proxy, '\
74
+ 'The expected input is comma separated values and you can use * wildcard metacharacters'\
75
+ 'For example: foo*, *b*,*bar'),
76
+ default: [],
77
+ full_name: N_('Ansible roles to ignore')
78
+ setting 'foreman_ansible_proxy_batch_size',
79
+ type: :integer,
80
+ description: N_('Number of tasks which should be sent to the smart proxy in one request, '\
81
+ 'if foreman_tasks_proxy_batch_trigger is enabled. '\
82
+ 'If set, overrides foreman_tasks_proxy_batch_size setting for Ansible jobs.'),
83
+ default: nil,
84
+ full_name: N_('Proxy tasks batch size for Ansible')
85
+ end
86
+ end
87
+
88
+ security_block :foreman_ansible do
89
+ permission :play_roles_on_host,
90
+ { :hosts => [:play_roles, :multiple_play_roles],
91
+ :'api/v2/hosts' => [:play_roles,
92
+ :multiple_play_roles] },
93
+ :resource_type => 'Host'
94
+ permission :play_roles_on_hostgroup,
95
+ { :hostgroups => [:play_roles],
96
+ :'api/v2/hostgroups' => [:play_roles,
97
+ :multiple_play_roles] },
98
+ :resource_type => 'Hostgroup'
99
+ permission :view_ansible_roles,
100
+ { :ansible_roles => [:index, :auto_complete_search],
101
+ :'api/v2/ansible_roles' => [:index, :show, :fetch],
102
+ :ui_ansible_roles => [:index] },
103
+ :resource_type => 'AnsibleRole'
104
+ permission :destroy_ansible_roles,
105
+ { :ansible_roles => [:destroy],
106
+ :'api/v2/ansible_roles' => [:destroy, :obsolete] },
107
+ :resource_type => 'AnsibleRole'
108
+ permission :import_ansible_roles,
109
+ { :ansible_roles => [:import, :confirm_import],
110
+ :'api/v2/ansible_roles' => [:import, :sync] },
111
+ :resource_type => 'AnsibleRole'
112
+ permission :view_ansible_variables,
113
+ {
114
+ :lookup_values => [:index],
115
+ :ansible_variables => [:index, :auto_complete_search],
116
+ :'api/v2/ansible_variables' => [:index, :show]
117
+ },
118
+ :resource_type => 'AnsibleVariable'
119
+ permission :edit_ansible_variables,
120
+ { :lookup_values => [:update],
121
+ :ansible_variables => [:edit, :update],
122
+ :'api/v2/ansible_variables' => [:update],
123
+ :'api/v2/ansible_override_values' => [:create, :destroy] },
124
+ :resource_type => 'AnsibleVariable'
125
+ permission :destroy_ansible_variables,
126
+ {
127
+ :lookup_values => [:destroy],
128
+ :ansible_variables => [:destroy],
129
+ :'api/v2/ansible_variables' => [:destroy, :obsolete]
130
+ },
131
+ :resource_type => 'AnsibleVariable'
132
+ permission :create_ansible_variables,
133
+ {
134
+ :lookup_values => [:create],
135
+ :ansible_variables => [:new, :create],
136
+ :'api/v2/ansible_variables' => [:create]
137
+ },
138
+ :resource_type => 'AnsibleVariable'
139
+ permission :import_ansible_variables,
140
+ {
141
+ :ansible_variables => [:import, :confirm_import],
142
+ :'api/v2/ansible_variables' => [:import]
143
+ },
144
+ :resource_type => 'AnsibleVariable'
145
+ permission :view_hosts,
146
+ { :'api/v2/hosts' => [:ansible_roles],
147
+ :'api/v2/ansible_inventories' => [:hosts] },
148
+ :resource_type => 'Host'
149
+ permission :view_hostgroups,
150
+ { :'api/v2/hostgroups' => [:ansible_roles],
151
+ :'api/v2/ansible_inventories' => [:hostgroups] },
152
+ :resource_type => 'Hostgroup'
153
+ permission :edit_hosts,
154
+ { :'api/v2/hosts' => [:assign_ansible_roles] },
155
+ :resource_type => 'Host'
156
+ permission :edit_hostgroups,
157
+ { :'api/v2/hostgroups' => [:assign_ansible_roles] },
158
+ :resource_type => 'Hostgroup'
159
+ permission :generate_ansible_inventory,
160
+ { :'api/v2/ansible_inventories' => [:schedule] }
161
+ permission :import_ansible_playbooks,
162
+ { :'api/v2/ansible_playbooks' => [:sync, :fetch] }
163
+ end
164
+
165
+ role 'Ansible Roles Manager',
166
+ [:play_roles_on_host, :play_roles_on_hostgroup,
167
+ :create_job_invocations, :view_job_templates, # to allow the play_roles
168
+ :create_template_invocations, :view_smart_proxies, # ...
169
+ :view_ansible_roles, :destroy_ansible_roles,
170
+ :import_ansible_roles, :view_ansible_variables,
171
+ :create_ansible_variables, :import_ansible_variables,
172
+ :edit_ansible_variables, :destroy_ansible_variables, :import_ansible_playbooks]
173
+
174
+ role 'Ansible Tower Inventory Reader',
175
+ [:view_hosts, :view_hostgroups, :view_facts, :generate_report_templates, :generate_ansible_inventory,
176
+ :view_report_templates],
177
+ 'Permissions required for the user which is used by Ansible Tower Dynamic Inventory Item'
178
+
179
+ add_all_permissions_to_default_roles
180
+ extend_template_helpers ForemanAnsible::RendererMethods
181
+ allowed_template_helpers :insights_remediation
182
+
183
+ base_role_assignment_params = { :ansible_role_ids => [],
184
+ :ansible_roles => [] }
185
+ parameter_filter Host::Managed, base_role_assignment_params.merge(:host_ansible_roles_attributes => {})
186
+ parameter_filter Hostgroup, base_role_assignment_params.merge(:hostgroup_ansible_roles_attributes => {})
187
+
188
+ register_global_js_file 'global'
189
+
190
+ extend_graphql_type :type => '::Types::Host' do
191
+ field :all_ansible_roles, ::Types::InheritedAnsibleRole.connection_type, :null => true, :method => :present_all_ansible_roles
192
+ field :own_ansible_roles, ::Types::AnsibleRole.connection_type, :null => true
193
+ field :available_ansible_roles, ::Types::AnsibleRole.connection_type, :null => true
194
+ field :ansible_variables_with_overrides, Types::OverridenAnsibleVariable.connection_type, :null => false
195
+
196
+ def present_all_ansible_roles
197
+ inherited_ansible_roles = object.inherited_ansible_roles.map { |role| ::Presenters::AnsibleRolePresenter.new(role, true) }
198
+ ansible_roles = object.ansible_roles.map { |role| ::Presenters::AnsibleRolePresenter.new(role, false) }
199
+ (inherited_ansible_roles + ansible_roles).uniq
200
+ end
201
+
202
+ def ansible_variables_with_overrides
203
+ resolver = ::ForemanAnsible::OverrideResolver.new(object)
204
+ AnsibleVariable.where(:ansible_role_id => object.all_ansible_roles.pluck(:id), :override => true).map { |variable| ::Presenters::OverridenAnsibleVariablePresenter.new variable, resolver }
205
+ end
206
+ end
207
+
208
+ register_graphql_query_field :ansible_roles, '::Types::AnsibleRole', :collection_field
209
+ register_graphql_mutation_field :assign_ansible_roles, '::Mutations::Hosts::AssignAnsibleRoles'
210
+ register_graphql_mutation_field :delete_ansible_variable_override, ::Mutations::AnsibleVariableOverrides::Delete
211
+ register_graphql_mutation_field :update_ansible_variable_override, ::Mutations::AnsibleVariableOverrides::Update
212
+ register_graphql_mutation_field :create_ansible_variable_override, ::Mutations::AnsibleVariableOverrides::Create
213
+
214
+ divider :top_menu, :caption => N_('Ansible'), :parent => :configure_menu
215
+ menu :top_menu, :ansible_roles,
216
+ :caption => N_('Roles'),
217
+ :url_hash => { :controller => :ansible_roles, :action => :index },
218
+ :parent => :configure_menu
219
+ menu :top_menu, :ansible_variables,
220
+ :caption => N_('Variables'),
221
+ :url_hash => { :controller => :ansible_variables, :action => :index },
222
+ :parent => :configure_menu
223
+
224
+ apipie_documented_controllers [
225
+ "#{ForemanAnsible::Engine.root}/app/controllers/api/v2/*.rb"
226
+ ]
227
+ ApipieDSL.configuration.dsl_classes_matchers += [
228
+ "#{ForemanAnsible::Engine.root}/app/models/*.rb",
229
+ "#{ForemanAnsible::Engine.root}/app/services/foreman_ansible/*.rb"
230
+ ]
231
+
232
+ register_info_provider ForemanAnsible::AnsibleInfo
233
+
234
+ # For backwards compatiblity with 1.17
235
+ if respond_to?(:register_report_scanner)
236
+ register_report_scanner ForemanAnsible::AnsibleReportScanner
237
+ register_report_origin 'Ansible', 'ConfigReport'
238
+ end
239
+
240
+ <<<<<<< HEAD
241
+ describe_host do
242
+ multiple_actions_provider :ansible_hosts_multiple_actions
243
+ =======
244
+ extend_page('smart_proxies/show') do |context|
245
+ context.add_pagelet :smart_proxy_title_actions,
246
+ :name => _('Update Smart Proxy'),
247
+ :partial => 'foreman/smart_proxies/update_smart_proxy',
248
+ :onlyif => ->(proxy, view) { view.can_update_proxy?(proxy) }
249
+ end
250
+ extend_page('smart_proxies/index') do |context|
251
+ context.add_pagelet :smart_proxy_title_actions,
252
+ :name => _('Update Smart Proxy'),
253
+ :partial => 'foreman/smart_proxies/update_smart_proxy',
254
+ :onlyif => ->(proxy, view) { view.can_update_proxy?(proxy) }
255
+ >>>>>>> a707dab (Fixes #35143 - Add a smart proxy update button)
256
+ end
257
+ end
@@ -48,12 +48,6 @@ module ForemanAnsible
48
48
  :description => N_('Upgrade Capsules on given Capsule server hosts'),
49
49
  :proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
50
50
  )
51
- RemoteExecutionFeature.register(
52
- :ansible_configure_cloud_connector,
53
- N_('Configure Cloud Connector on given hosts'),
54
- :description => N_('Configure Cloud Connector on given hosts'),
55
- :proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
56
- )
57
51
  end
58
52
  end
59
53
  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 = '7.1.1'
7
+ VERSION = '7.1.4'
8
8
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -54,6 +54,7 @@ const EditRolesModal = ({
54
54
 
55
55
  const renameData = data => ({
56
56
  availableRoles: data.host.availableAnsibleRoles.nodes,
57
+ assignedRoles,
57
58
  });
58
59
 
59
60
  return (
@@ -64,7 +65,7 @@ const EditRolesModal = ({
64
65
  baseModalProps={baseModalProps}
65
66
  fetchFn={useFetchFn}
66
67
  renameData={renameData}
67
- renamedDataPath="availableRoles"
68
+ renamedDataPath="availableRoles.assignedRoles"
68
69
  assignedRoles={assignedRoles}
69
70
  closeModal={closeModal}
70
71
  hostId={hostId}
@@ -21,7 +21,8 @@ import {
21
21
  assignRolesErrorMock,
22
22
  } from './RolesTab.fixtures';
23
23
 
24
- const TestComponent = withReactRouter(withRedux(withMockedProvider(RolesTab)));
24
+ jest.mock('axios');
25
+ const TestComponent = withRedux(withReactRouter(withMockedProvider(RolesTab)));
25
26
 
26
27
  describe('assigning Ansible roles', () => {
27
28
  it('should assign Ansible roles', async () => {
@@ -6,6 +6,7 @@ import {
6
6
  tick,
7
7
  withMockedProvider,
8
8
  withReactRouter,
9
+ withRedux,
9
10
  } from '../../../../../testHelper';
10
11
 
11
12
  import {
@@ -18,7 +19,8 @@ import {
18
19
 
19
20
  import RolesTab from '../';
20
21
 
21
- const TestComponent = withReactRouter(withMockedProvider(RolesTab));
22
+ jest.mock('axios');
23
+ const TestComponent = withRedux(withReactRouter(withMockedProvider(RolesTab)));
22
24
 
23
25
  describe('RolesTab', () => {
24
26
  it('should load Ansible Roles as admin', async () => {
@@ -2,7 +2,10 @@ import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useQuery } from '@apollo/client';
4
4
  import { Button } from '@patternfly/react-core';
5
+ import { Link, Route } from 'react-router-dom';
5
6
  import { translate as __ } from 'foremanReact/common/I18n';
7
+ import { foremanUrl } from 'foremanReact/common/helpers';
8
+ import { useAPI } from 'foremanReact/common/hooks/API/APIHooks';
6
9
 
7
10
  import ansibleRolesQuery from '../../../../graphql/queries/hostAnsibleRoles.gql';
8
11
  import { encodeId } from '../../../../globalIdHelper';
@@ -12,6 +15,7 @@ import {
12
15
  useCurrentPagination,
13
16
  } from '../../../../helpers/pageParamsHelper';
14
17
  import EditRolesModal from './EditRolesModal';
18
+ import AllRolesModal from './AllRolesModal';
15
19
 
16
20
  const RolesTab = ({ hostId, history, canEditHost }) => {
17
21
  const hostGlobalId = encodeId('Host', hostId);
@@ -33,9 +37,28 @@ const RolesTab = ({ hostId, history, canEditHost }) => {
33
37
  onClick={() => setAssignModal(true)}
34
38
  aria-label="edit ansible roles"
35
39
  >
36
- {__('Assign Ansible roles')}
40
+ {__('Assign roles directly to the host')}
37
41
  </Button>
38
42
  ) : null;
43
+
44
+ const url = hostId && foremanUrl(`/api/v2/hosts/${hostId}/ansible_roles`);
45
+ const { response: allAnsibleRoles } = useAPI('get', url, {
46
+ key: 'ANSIBLE_ROLES',
47
+ });
48
+ const emptyStateDescription = allAnsibleRoles.length > 0 && (
49
+ <>
50
+ <Route path="/Ansible/roles/all">
51
+ <AllRolesModal
52
+ onClose={() => history.push('/Ansible/roles')}
53
+ isOpen
54
+ hostGlobalId={hostGlobalId}
55
+ history={history}
56
+ />
57
+ </Route>
58
+ <Link to="/Ansible/roles/all">{__('View inherited roles')}</Link>
59
+ </>
60
+ );
61
+
39
62
  return (
40
63
  <>
41
64
  <RolesTable
@@ -46,8 +69,9 @@ const RolesTab = ({ hostId, history, canEditHost }) => {
46
69
  history={history}
47
70
  hostGlobalId={hostGlobalId}
48
71
  emptyStateProps={{
49
- header: __('No Ansible roles assigned'),
72
+ header: __('No roles assigned directly to the host'),
50
73
  action: editBtn,
74
+ description: emptyStateDescription,
51
75
  }}
52
76
  pagination={pagination}
53
77
  canEditHost={canEditHost}
@@ -13,14 +13,12 @@ import {
13
13
  } from '../permissionsHelper';
14
14
  import ErrorState from './ErrorState';
15
15
 
16
- const pluckData = (data, path) => {
16
+ const getResultsLength = (data, path) => {
17
17
  const split = path.split('.');
18
- return split.reduce((memo, item) => {
19
- if (item) {
20
- return memo[item];
21
- }
22
- throw new Error('Unexpected empty segment in response data path');
23
- }, data);
18
+ return split.reduce(
19
+ (prevValue, currentValue) => prevValue + data[currentValue]?.length || 0,
20
+ 0
21
+ );
24
22
  };
25
23
 
26
24
  const withLoading = Component => {
@@ -79,12 +77,9 @@ const withLoading = Component => {
79
77
  }
80
78
 
81
79
  const renamedData = renameData(data);
82
- const result = pluckData(renamedData, renamedDataPath);
80
+ const resultLength = getResultsLength(renamedData, renamedDataPath);
83
81
 
84
- if (
85
- showEmptyState &&
86
- ((Array.isArray(result) && result.length === 0) || !result)
87
- ) {
82
+ if (showEmptyState && !resultLength) {
88
83
  return emptyWrapper(
89
84
  <EmptyState
90
85
  {...{
@@ -1,15 +1,24 @@
1
1
  import React from 'react';
2
2
  import { Provider } from 'react-redux';
3
+ import thunk from 'redux-thunk';
4
+ import { applyMiddleware, createStore, compose, combineReducers } from 'redux';
3
5
  import { MockedProvider } from '@apollo/react-testing';
4
6
  import { Router, MemoryRouter } from 'react-router-dom';
5
7
  import { createMemoryHistory } from 'history';
6
8
 
7
- import store from 'foremanReact/redux';
8
- import ConfirmModal from 'foremanReact/components/ConfirmModal';
9
+ import { reducers as apiReducer, APIMiddleware } from 'foremanReact/redux/API';
10
+ import ConfirmModal, {
11
+ reducers as confirmModalReducers,
12
+ } from 'foremanReact/components/ConfirmModal';
9
13
  import { getForemanContext } from 'foremanReact/Root/Context/ForemanContext';
10
14
 
15
+ const reducers = combineReducers({ ...apiReducer, ...confirmModalReducers });
16
+
17
+ export const generateStore = () =>
18
+ createStore(reducers, compose(applyMiddleware(thunk, APIMiddleware)));
19
+
11
20
  export const withRedux = Component => props => (
12
- <Provider store={store}>
21
+ <Provider store={generateStore()}>
13
22
  <Component {...props} />
14
23
  <ConfirmModal />
15
24
  </Provider>
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: 7.1.1
4
+ version: 7.1.4
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: 2022-07-15 00:00:00.000000000 Z
11
+ date: 2022-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_list
@@ -186,7 +186,6 @@ files:
186
186
  - app/views/foreman_ansible/job_templates/ansible_roles_-_install_from_git.erb
187
187
  - app/views/foreman_ansible/job_templates/ansible_windows_updates.erb
188
188
  - app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb
189
- - app/views/foreman_ansible/job_templates/configure_cloud_connector_-_ansible_default.erb
190
189
  - app/views/foreman_ansible/job_templates/convert_to_rhel.erb
191
190
  - app/views/foreman_ansible/job_templates/maintenance_plan.erb
192
191
  - app/views/foreman_ansible/job_templates/module_action_-_ansible_default.erb
@@ -224,6 +223,7 @@ files:
224
223
  - lib/foreman_ansible.rb
225
224
  - lib/foreman_ansible/engine.rb
226
225
  - lib/foreman_ansible/register.rb
226
+ - lib/foreman_ansible/register.rb.orig
227
227
  - lib/foreman_ansible/remote_execution.rb
228
228
  - lib/foreman_ansible/version.rb
229
229
  - locale/Makefile
@@ -496,55 +496,55 @@ required_rubygems_version: !ruby/object:Gem::Requirement
496
496
  - !ruby/object:Gem::Version
497
497
  version: '0'
498
498
  requirements: []
499
- rubygems_version: 3.3.7
499
+ rubygems_version: 3.1.6
500
500
  signing_key:
501
501
  specification_version: 4
502
502
  summary: Ansible integration with Foreman (theforeman.org)
503
503
  test_files:
504
+ - test/factories/ansible_proxy.rb
505
+ - test/factories/ansible_roles.rb
506
+ - test/factories/ansible_variables.rb
507
+ - test/factories/host_ansible_enhancements.rb
508
+ - test/fixtures/insights_playbook.yaml
509
+ - test/fixtures/playbooks_example_output.json
510
+ - test/fixtures/report.json
511
+ - test/fixtures/sample_facts.json
512
+ - test/fixtures/sample_playbooks.json
513
+ - test/foreman_ansible/helpers/ansible_roles_helper_test.rb
514
+ - test/functional/api/v2/ansible_inventories_controller_test.rb
504
515
  - test/functional/api/v2/ansible_playbooks_controller_test.rb
505
- - test/functional/api/v2/hosts_controller_test.rb
506
516
  - test/functional/api/v2/ansible_roles_controller_test.rb
507
- - test/functional/api/v2/hostgroups_controller_test.rb
508
517
  - test/functional/api/v2/ansible_variables_controller_test.rb
509
- - test/functional/api/v2/ansible_inventories_controller_test.rb
510
- - test/functional/hosts_controller_test.rb
518
+ - test/functional/api/v2/hostgroups_controller_test.rb
519
+ - test/functional/api/v2/hosts_controller_test.rb
511
520
  - test/functional/ansible_roles_controller_test.rb
512
521
  - test/functional/ansible_variables_controller_test.rb
522
+ - test/functional/hosts_controller_test.rb
513
523
  - test/functional/ui_ansible_roles_controller_test.rb
514
- - test/unit/services/inventory_creator_test.rb
524
+ - test/graphql/mutations/hosts/assign_ansible_roles_mutation_test.rb
525
+ - test/graphql/queries/ansible_roles_query_test.rb
526
+ - test/graphql/queries/host_ansible_roles_query_test.rb
527
+ - test/unit/actions/run_ansible_job_test.rb
528
+ - test/unit/actions/run_proxy_ansible_command_test.rb
529
+ - test/unit/concerns/config_reports_extensions_test.rb
530
+ - test/unit/concerns/host_managed_extensions_test.rb
531
+ - test/unit/concerns/hostgroup_extensions_test.rb
532
+ - test/unit/helpers/ansible_reports_helper_test.rb
533
+ - test/unit/lib/proxy_api/ansible_test.rb
515
534
  - test/unit/services/ansible_report_importer_test.rb
516
- - test/unit/services/ui_roles_importer_test.rb
517
- - test/unit/services/roles_importer_test.rb
518
535
  - test/unit/services/ansible_variables_importer_test.rb
519
- - test/unit/services/override_resolver_test.rb
520
536
  - test/unit/services/api_roles_importer_test.rb
521
537
  - test/unit/services/insights_plan_runner_test.rb
538
+ - test/unit/services/inventory_creator_test.rb
539
+ - test/unit/services/override_resolver_test.rb
540
+ - test/unit/services/roles_importer_test.rb
541
+ - test/unit/services/ui_roles_importer_test.rb
542
+ - test/unit/ansible_provider_test.rb
522
543
  - test/unit/ansible_role_test.rb
544
+ - test/unit/ansible_variable_test.rb
523
545
  - test/unit/host_ansible_role_test.rb
524
- - test/unit/import_playbooks_test.rb
525
546
  - test/unit/hostgroup_ansible_role_test.rb
526
- - test/unit/helpers/ansible_reports_helper_test.rb
527
- - test/unit/ansible_provider_test.rb
528
- - test/unit/concerns/host_managed_extensions_test.rb
529
- - test/unit/concerns/config_reports_extensions_test.rb
530
- - test/unit/concerns/hostgroup_extensions_test.rb
531
547
  - test/unit/ignore_roles_test.rb
532
- - test/unit/ansible_variable_test.rb
548
+ - test/unit/import_playbooks_test.rb
533
549
  - test/unit/import_roles_and_variables.rb
534
- - test/unit/lib/proxy_api/ansible_test.rb
535
- - test/unit/actions/run_ansible_job_test.rb
536
- - test/unit/actions/run_proxy_ansible_command_test.rb
537
- - test/foreman_ansible/helpers/ansible_roles_helper_test.rb
538
550
  - test/test_plugin_helper.rb
539
- - test/factories/ansible_proxy.rb
540
- - test/factories/ansible_variables.rb
541
- - test/factories/host_ansible_enhancements.rb
542
- - test/factories/ansible_roles.rb
543
- - test/fixtures/playbooks_example_output.json
544
- - test/fixtures/report.json
545
- - test/fixtures/sample_facts.json
546
- - test/fixtures/insights_playbook.yaml
547
- - test/fixtures/sample_playbooks.json
548
- - test/graphql/mutations/hosts/assign_ansible_roles_mutation_test.rb
549
- - test/graphql/queries/host_ansible_roles_query_test.rb
550
- - test/graphql/queries/ansible_roles_query_test.rb
@@ -1,37 +0,0 @@
1
- <%#
2
- name: Configure Cloud Connector
3
- snippet: false
4
- template_inputs:
5
- - name: satellite_user
6
- required: true
7
- input_type: user
8
- advanced: false
9
- value_type: plain
10
- hidden_value: false
11
- - name: satellite_password
12
- required: true
13
- input_type: user
14
- advanced: false
15
- value_type: plain
16
- hidden_value: true
17
- - name: http_proxy
18
- required: false
19
- input_type: user
20
- advanced: true
21
- value_type: plain
22
- hidden_value: false
23
- description: You can specify a HTTP proxy address that should be used for Cloud Connector connection to the cloud.redhat.com. Note that it must be HTTP proxy, not HTTPS. The tunelling of SSL (secured web socket connection) in SSL (HTTPS proxy) is currently unsupported.
24
- model: JobTemplate
25
- job_category: Maintenance Operations
26
- description_format: "%{template_name}"
27
- provider_type: Ansible
28
- kind: job_template
29
- feature: ansible_configure_cloud_connector
30
- %>
31
-
32
- ---
33
- - hosts: all
34
- vars:
35
- satellite_url: "<%= foreman_server_url %>"
36
- roles:
37
- - project-receptor.satellite_receptor_installer