foreman_ansible 8.0.0 → 9.0.1
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 +15 -0
- data/app/helpers/foreman_ansible/ansible_reports_helper.rb +0 -4
- data/app/models/concerns/foreman_ansible/hostgroup_extensions.rb +13 -0
- data/app/views/ansible_roles/index.html.erb +1 -1
- data/db/migrate/20200421201839_update_ansible_inv_template_name.rb +1 -5
- data/lib/foreman_ansible/register.rb +5 -1
- data/lib/foreman_ansible/register.rb.orig +257 -0
- data/lib/foreman_ansible/version.rb +1 -1
- data/locale/ca/foreman_ansible.edit.po +0 -0
- data/locale/ca/foreman_ansible.po.time_stamp +0 -0
- data/locale/cs_CZ/foreman_ansible.edit.po +0 -0
- data/locale/cs_CZ/foreman_ansible.po.time_stamp +0 -0
- data/locale/de/foreman_ansible.edit.po +0 -0
- data/locale/de/foreman_ansible.po.time_stamp +0 -0
- data/locale/en/foreman_ansible.edit.po +0 -0
- data/locale/en/foreman_ansible.po.time_stamp +0 -0
- data/locale/en_GB/foreman_ansible.edit.po +0 -0
- data/locale/en_GB/foreman_ansible.po.time_stamp +0 -0
- data/locale/es/foreman_ansible.edit.po +0 -0
- data/locale/es/foreman_ansible.po.time_stamp +0 -0
- data/locale/fr/foreman_ansible.edit.po +0 -0
- data/locale/fr/foreman_ansible.po.time_stamp +0 -0
- data/locale/gl/foreman_ansible.edit.po +0 -0
- data/locale/gl/foreman_ansible.po.time_stamp +0 -0
- data/locale/it/foreman_ansible.edit.po +0 -0
- data/locale/it/foreman_ansible.po.time_stamp +0 -0
- data/locale/ja/foreman_ansible.edit.po +0 -0
- data/locale/ja/foreman_ansible.po.time_stamp +0 -0
- data/locale/ko/foreman_ansible.edit.po +0 -0
- data/locale/ko/foreman_ansible.po.time_stamp +0 -0
- data/locale/nl_NL/foreman_ansible.edit.po +0 -0
- data/locale/nl_NL/foreman_ansible.po.time_stamp +0 -0
- data/locale/pl/foreman_ansible.edit.po +0 -0
- data/locale/pl/foreman_ansible.po.time_stamp +0 -0
- data/locale/pt_BR/foreman_ansible.edit.po +0 -0
- data/locale/pt_BR/foreman_ansible.po.time_stamp +0 -0
- data/locale/ru/foreman_ansible.edit.po +0 -0
- data/locale/ru/foreman_ansible.po.time_stamp +0 -0
- data/locale/sv_SE/foreman_ansible.edit.po +0 -0
- data/locale/sv_SE/foreman_ansible.po.time_stamp +0 -0
- data/locale/zh_CN/foreman_ansible.edit.po +0 -0
- data/locale/zh_CN/foreman_ansible.po.time_stamp +0 -0
- data/locale/zh_TW/foreman_ansible.edit.po +0 -0
- data/locale/zh_TW/foreman_ansible.po.time_stamp +0 -0
- data/package.json +6 -6
- data/test/unit/concerns/hostgroup_extensions_test.rb +5 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/PreviousJobsTable.js.orig +0 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/EditRolesForm.js +10 -8
- data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/index.js +1 -1
- data/webpack/components/ReportJsonViewer.js +11 -1
- metadata +36 -36
- data/app/overrides/hostgroup_play_roles.rb +0 -9
- data/app/views/foreman_ansible/ansible_roles/_hostgroup_ansible_roles_button.erb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf08e369d1c4b9a445123a9fab3a02b1da8c3bfe9261b7027693959d90e1e1a3
|
4
|
+
data.tar.gz: 13ac8e3cb9b88bf5167a2fdeb9e95409ad9a93c6f4dce12f0500cc5c5bd787a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c515c517add1b91f020c63a50b6b58eaafdacfe08d52d39286ae79efd034cb8ca0ffc8ef4aa8aa2f5be9e5dcc6a797910dd9b32f444e61e525077c8239e3e56
|
7
|
+
data.tar.gz: 18fac58f8a1d119af822b6be9f28ce33b626b0951791d5c3ca201d6e2475f2399c52d21ba92b19335f267a183306e568cbc384910942f1d7d0de9d1d74a88ef2
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanAnsible
|
4
|
+
module AnsibleHostgroupsHelper
|
5
|
+
def ansible_hostgroups_actions(hostgroup)
|
6
|
+
play_roles = if hostgroup.all_ansible_roles.empty?
|
7
|
+
{ action: (link_to _('Run all Ansible roles'), 'javascript:void(0);', disabled: true, title: 'No Roles assigned'), priority: 31 }
|
8
|
+
else
|
9
|
+
{ 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
|
+
end
|
11
|
+
|
12
|
+
[play_roles] if User.current.can?(:create_job_invocations)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -11,6 +11,9 @@ module ForemanAnsible
|
|
11
11
|
-> { order('hostgroup_ansible_roles.position ASC') },
|
12
12
|
:through => :hostgroup_ansible_roles,
|
13
13
|
:dependent => :destroy
|
14
|
+
scoped_search :relation => :ansible_roles, :on => :name,
|
15
|
+
:complete_value => true, :rename => :ansible_role,
|
16
|
+
:only_explicit => true, :operators => ['= ', '!= ', '~ ', '!~ '], :ext_method => :search_by_role
|
14
17
|
accepts_nested_attributes_for :hostgroup_ansible_roles, :allow_destroy => true
|
15
18
|
audit_associations :ansible_roles
|
16
19
|
include_in_clone :ansible_roles
|
@@ -38,6 +41,16 @@ module ForemanAnsible
|
|
38
41
|
(inherited_ansible_roles + ansible_roles + host_ansible_roles).uniq
|
39
42
|
end
|
40
43
|
end
|
44
|
+
|
45
|
+
class_methods do
|
46
|
+
def search_by_role(_key, operator, value)
|
47
|
+
conditions = sanitize_sql_for_conditions(["ansible_roles.name #{operator} ?", value_to_sql(operator, value)])
|
48
|
+
hostgroup_ids = ::Hostgroup.joins(:ansible_roles).where(conditions).map(&:subtree_ids).flatten
|
49
|
+
|
50
|
+
conds = "hostgroups.id IN(#{hostgroup_ids.join(',')})" if hostgroup_ids.present?
|
51
|
+
{ conditions: conds.presence || '1 = 0' }
|
52
|
+
end
|
53
|
+
end
|
41
54
|
end
|
42
55
|
end
|
43
56
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<% @ansible_roles.each do |role| %>
|
19
19
|
<tr>
|
20
20
|
<td class="ellipsis"><%= role.name %></td>
|
21
|
-
<td class="ellipsis"><%= role.hostgroups.count %></td>
|
21
|
+
<td class="ellipsis"><%= link_to role.hostgroups.count, hostgroups_path(:search => "ansible_role = #{role.name}") %></td>
|
22
22
|
<td class="ellipsis"><%= link_to role.hosts.count, hosts_path(:search => "ansible_role = #{role.name}")%></td>
|
23
23
|
<td class="ellipsis"><%= link_to(role.ansible_variables.count, ansible_variables_path(:search => "ansible_role = #{role}")) %></td>
|
24
24
|
<td class="ellipsis"><%= import_time role %></td>
|
@@ -1,9 +1,5 @@
|
|
1
1
|
class UpdateAnsibleInvTemplateName < ActiveRecord::Migration[5.2]
|
2
2
|
def up
|
3
|
-
Setting
|
4
|
-
end
|
5
|
-
|
6
|
-
def down
|
7
|
-
Setting.where(:name => 'ansible_inventory_template').update_all(:default => 'Ansible Inventory')
|
3
|
+
# Setting defaults are updated automatically now
|
8
4
|
end
|
9
5
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Foreman::Plugin.register :foreman_ansible do
|
4
|
-
requires_foreman '>= 3.
|
4
|
+
requires_foreman '>= 3.4'
|
5
5
|
|
6
6
|
settings do
|
7
7
|
category :ansible, N_('Ansible') do
|
@@ -240,4 +240,8 @@ Foreman::Plugin.register :foreman_ansible do
|
|
240
240
|
describe_host do
|
241
241
|
multiple_actions_provider :ansible_hosts_multiple_actions
|
242
242
|
end
|
243
|
+
|
244
|
+
describe_hostgroup do
|
245
|
+
hostgroup_actions_provider :ansible_hostgroups_actions
|
246
|
+
end
|
243
247
|
end
|
@@ -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
|
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
|
data/package.json
CHANGED
@@ -15,12 +15,12 @@
|
|
15
15
|
"devDependencies": {
|
16
16
|
"@babel/core": "^7.7.0",
|
17
17
|
"@testing-library/user-event": "^13.2.1",
|
18
|
-
"@theforeman/builder": "^
|
19
|
-
"@theforeman/eslint-plugin-foreman": "^
|
20
|
-
"@theforeman/find-foreman": "^
|
21
|
-
"@theforeman/stories": "^
|
22
|
-
"@theforeman/test": "^
|
23
|
-
"@theforeman/vendor-dev": "^
|
18
|
+
"@theforeman/builder": "^10.0",
|
19
|
+
"@theforeman/eslint-plugin-foreman": "^10.0",
|
20
|
+
"@theforeman/find-foreman": "^10.0",
|
21
|
+
"@theforeman/stories": "^10.0",
|
22
|
+
"@theforeman/test": "^10.0",
|
23
|
+
"@theforeman/vendor-dev": "^10.0",
|
24
24
|
"@testing-library/user-event": "^13.2.1",
|
25
25
|
"babel-eslint": "^10.0.3",
|
26
26
|
"eslint": "^6.7.2",
|
@@ -61,4 +61,9 @@ class HostgroupExtensionsTest < ActiveSupport::TestCase
|
|
61
61
|
@hostgroup_parent.clone.all_ansible_roles.must_equal @hostgroup_parent.all_ansible_roles
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
test 'should find hostgroup with role' do
|
66
|
+
result = ::Hostgroup.search_for("ansible_role = #{@role1.name}").pluck(:id)
|
67
|
+
assert_include result, @hostgroup.id
|
68
|
+
end
|
64
69
|
end
|
File without changes
|
data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/EditRolesForm.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useState } from 'react';
|
2
2
|
import { translate as __ } from 'foremanReact/common/I18n';
|
3
3
|
import PropTypes from 'prop-types';
|
4
|
-
|
4
|
+
import { isEqual } from 'lodash';
|
5
5
|
import { useMutation } from '@apollo/client';
|
6
6
|
|
7
7
|
import { Button, Modal, Spinner } from '@patternfly/react-core';
|
@@ -21,12 +21,10 @@ const EditRolesForm = props => {
|
|
21
21
|
actions,
|
22
22
|
} = props;
|
23
23
|
|
24
|
-
const
|
25
|
-
|
26
|
-
);
|
27
|
-
const [chosenOptions, setChosenOptions] = useState(
|
28
|
-
assignedRoles.map(item => item.name)
|
29
|
-
);
|
24
|
+
const initAvailableOpt = availableRoles.map(item => item.name);
|
25
|
+
const initChosenOpt = assignedRoles.map(item => item.name);
|
26
|
+
const [availableOptions, setAvailableOptions] = useState(initAvailableOpt);
|
27
|
+
const [chosenOptions, setChosenOptions] = useState(initChosenOpt);
|
30
28
|
|
31
29
|
const onListChange = (nextAvailable, nextChosen) => {
|
32
30
|
setAvailableOptions(nextAvailable);
|
@@ -45,12 +43,16 @@ const EditRolesForm = props => {
|
|
45
43
|
ansibleRoleIds: roleNamesToIds(allRoles, chosenOptions),
|
46
44
|
};
|
47
45
|
|
46
|
+
const didNotModifyOptions = () =>
|
47
|
+
isEqual(initAvailableOpt.sort(), availableOptions.sort()) &&
|
48
|
+
isEqual(initChosenOpt, chosenOptions); // The order of the chosen options is important.
|
49
|
+
|
48
50
|
const formActions = [
|
49
51
|
<Button
|
50
52
|
key="confirm"
|
51
53
|
variant="primary"
|
52
54
|
onClick={() => callMutation({ variables })}
|
53
|
-
isDisabled={loading}
|
55
|
+
isDisabled={loading || didNotModifyOptions()}
|
54
56
|
aria-label="submit ansible roles"
|
55
57
|
>
|
56
58
|
{__('Confirm')}
|
@@ -10,7 +10,17 @@ const theme = {
|
|
10
10
|
|
11
11
|
const ReportJsonViewer = ({ data }) => (
|
12
12
|
<div className="report-json-viewer">
|
13
|
-
<JSONTree
|
13
|
+
<JSONTree
|
14
|
+
data={data}
|
15
|
+
hideRoot
|
16
|
+
theme={theme}
|
17
|
+
shouldExpandNode={(keyPath, _myData, level) =>
|
18
|
+
keyPath[0] === '_meta' ||
|
19
|
+
keyPath[0] === 'hostvars' ||
|
20
|
+
level === 3 ||
|
21
|
+
keyPath[0] === 'foreman_ansible_roles'
|
22
|
+
}
|
23
|
+
/>
|
14
24
|
</div>
|
15
25
|
);
|
16
26
|
|
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:
|
4
|
+
version: 9.0.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: 2022-05
|
11
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_list
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- app/graphql/types/ansible_variable_override.rb
|
110
110
|
- app/graphql/types/inherited_ansible_role.rb
|
111
111
|
- app/graphql/types/overriden_ansible_variable.rb
|
112
|
+
- app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
|
112
113
|
- app/helpers/foreman_ansible/ansible_plugin_helper.rb
|
113
114
|
- app/helpers/foreman_ansible/ansible_reports_helper.rb
|
114
115
|
- app/helpers/foreman_ansible/ansible_roles_data_preparations.rb
|
@@ -127,7 +128,6 @@ files:
|
|
127
128
|
- app/models/hostgroup_ansible_role.rb
|
128
129
|
- app/overrides/ansible_roles_tab.rb
|
129
130
|
- app/overrides/hostgroup_ansible_roles_tab.rb
|
130
|
-
- app/overrides/hostgroup_play_roles.rb
|
131
131
|
- app/overrides/report_output.rb
|
132
132
|
- app/services/foreman_ansible/ansible_info.rb
|
133
133
|
- app/services/foreman_ansible/ansible_report_importer.rb
|
@@ -171,7 +171,6 @@ files:
|
|
171
171
|
- app/views/api/v2/ansible_variables/show.json.rabl
|
172
172
|
- app/views/api/v2/hostgroups/ansible_roles.json.rabl
|
173
173
|
- app/views/api/v2/hosts/ansible_roles.json.rabl
|
174
|
-
- app/views/foreman_ansible/ansible_roles/_hostgroup_ansible_roles_button.erb
|
175
174
|
- app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb
|
176
175
|
- app/views/foreman_ansible/ansible_roles/_select_tab_title.html.erb
|
177
176
|
- app/views/foreman_ansible/api/v2/ansible_roles/import.json.rabl
|
@@ -223,6 +222,7 @@ files:
|
|
223
222
|
- lib/foreman_ansible.rb
|
224
223
|
- lib/foreman_ansible/engine.rb
|
225
224
|
- lib/foreman_ansible/register.rb
|
225
|
+
- lib/foreman_ansible/register.rb.orig
|
226
226
|
- lib/foreman_ansible/remote_execution.rb
|
227
227
|
- lib/foreman_ansible/version.rb
|
228
228
|
- locale/Makefile
|
@@ -495,55 +495,55 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
495
495
|
- !ruby/object:Gem::Version
|
496
496
|
version: '0'
|
497
497
|
requirements: []
|
498
|
-
rubygems_version: 3.
|
498
|
+
rubygems_version: 3.1.6
|
499
499
|
signing_key:
|
500
500
|
specification_version: 4
|
501
501
|
summary: Ansible integration with Foreman (theforeman.org)
|
502
502
|
test_files:
|
503
|
+
- test/factories/ansible_proxy.rb
|
504
|
+
- test/factories/ansible_roles.rb
|
505
|
+
- test/factories/ansible_variables.rb
|
506
|
+
- test/factories/host_ansible_enhancements.rb
|
507
|
+
- test/fixtures/insights_playbook.yaml
|
508
|
+
- test/fixtures/playbooks_example_output.json
|
509
|
+
- test/fixtures/report.json
|
510
|
+
- test/fixtures/sample_facts.json
|
511
|
+
- test/fixtures/sample_playbooks.json
|
512
|
+
- test/foreman_ansible/helpers/ansible_roles_helper_test.rb
|
513
|
+
- test/functional/api/v2/ansible_inventories_controller_test.rb
|
503
514
|
- test/functional/api/v2/ansible_playbooks_controller_test.rb
|
504
|
-
- test/functional/api/v2/hosts_controller_test.rb
|
505
515
|
- test/functional/api/v2/ansible_roles_controller_test.rb
|
506
|
-
- test/functional/api/v2/hostgroups_controller_test.rb
|
507
516
|
- test/functional/api/v2/ansible_variables_controller_test.rb
|
508
|
-
- test/functional/api/v2/
|
509
|
-
- test/functional/hosts_controller_test.rb
|
517
|
+
- test/functional/api/v2/hostgroups_controller_test.rb
|
518
|
+
- test/functional/api/v2/hosts_controller_test.rb
|
510
519
|
- test/functional/ansible_roles_controller_test.rb
|
511
520
|
- test/functional/ansible_variables_controller_test.rb
|
521
|
+
- test/functional/hosts_controller_test.rb
|
512
522
|
- test/functional/ui_ansible_roles_controller_test.rb
|
513
|
-
- test/
|
523
|
+
- test/graphql/mutations/hosts/assign_ansible_roles_mutation_test.rb
|
524
|
+
- test/graphql/queries/ansible_roles_query_test.rb
|
525
|
+
- test/graphql/queries/host_ansible_roles_query_test.rb
|
526
|
+
- test/unit/actions/run_ansible_job_test.rb
|
527
|
+
- test/unit/actions/run_proxy_ansible_command_test.rb
|
528
|
+
- test/unit/concerns/config_reports_extensions_test.rb
|
529
|
+
- test/unit/concerns/host_managed_extensions_test.rb
|
530
|
+
- test/unit/concerns/hostgroup_extensions_test.rb
|
531
|
+
- test/unit/helpers/ansible_reports_helper_test.rb
|
532
|
+
- test/unit/lib/proxy_api/ansible_test.rb
|
514
533
|
- test/unit/services/ansible_report_importer_test.rb
|
515
|
-
- test/unit/services/ui_roles_importer_test.rb
|
516
|
-
- test/unit/services/roles_importer_test.rb
|
517
534
|
- test/unit/services/ansible_variables_importer_test.rb
|
518
|
-
- test/unit/services/override_resolver_test.rb
|
519
535
|
- test/unit/services/api_roles_importer_test.rb
|
520
536
|
- test/unit/services/insights_plan_runner_test.rb
|
537
|
+
- test/unit/services/inventory_creator_test.rb
|
538
|
+
- test/unit/services/override_resolver_test.rb
|
539
|
+
- test/unit/services/roles_importer_test.rb
|
540
|
+
- test/unit/services/ui_roles_importer_test.rb
|
541
|
+
- test/unit/ansible_provider_test.rb
|
521
542
|
- test/unit/ansible_role_test.rb
|
543
|
+
- test/unit/ansible_variable_test.rb
|
522
544
|
- test/unit/host_ansible_role_test.rb
|
523
|
-
- test/unit/import_playbooks_test.rb
|
524
545
|
- test/unit/hostgroup_ansible_role_test.rb
|
525
|
-
- test/unit/helpers/ansible_reports_helper_test.rb
|
526
|
-
- test/unit/ansible_provider_test.rb
|
527
|
-
- test/unit/concerns/host_managed_extensions_test.rb
|
528
|
-
- test/unit/concerns/config_reports_extensions_test.rb
|
529
|
-
- test/unit/concerns/hostgroup_extensions_test.rb
|
530
546
|
- test/unit/ignore_roles_test.rb
|
531
|
-
- test/unit/
|
547
|
+
- test/unit/import_playbooks_test.rb
|
532
548
|
- test/unit/import_roles_and_variables.rb
|
533
|
-
- test/unit/lib/proxy_api/ansible_test.rb
|
534
|
-
- test/unit/actions/run_ansible_job_test.rb
|
535
|
-
- test/unit/actions/run_proxy_ansible_command_test.rb
|
536
|
-
- test/foreman_ansible/helpers/ansible_roles_helper_test.rb
|
537
549
|
- test/test_plugin_helper.rb
|
538
|
-
- test/factories/ansible_proxy.rb
|
539
|
-
- test/factories/ansible_variables.rb
|
540
|
-
- test/factories/host_ansible_enhancements.rb
|
541
|
-
- test/factories/ansible_roles.rb
|
542
|
-
- test/fixtures/playbooks_example_output.json
|
543
|
-
- test/fixtures/report.json
|
544
|
-
- test/fixtures/sample_facts.json
|
545
|
-
- test/fixtures/insights_playbook.yaml
|
546
|
-
- test/fixtures/sample_playbooks.json
|
547
|
-
- test/graphql/mutations/hosts/assign_ansible_roles_mutation_test.rb
|
548
|
-
- test/graphql/queries/host_ansible_roles_query_test.rb
|
549
|
-
- test/graphql/queries/ansible_roles_query_test.rb
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Displays Ansible roles button in host group action buttons
|
4
|
-
Deface::Override.new(
|
5
|
-
:virtual_path => 'hostgroups/index',
|
6
|
-
:name => 'hostgroup_ansible_roles_button',
|
7
|
-
:replace => "erb[loud]:contains('action_buttons')",
|
8
|
-
:partial => 'foreman_ansible/ansible_roles/hostgroup_ansible_roles_button'
|
9
|
-
)
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%=
|
2
|
-
play_roles = if hostgroup.all_ansible_roles.empty?
|
3
|
-
link_to _('Run all Ansible roles'), 'javascript:void(0);', disabled: true, title: 'No Roles assigned'
|
4
|
-
else
|
5
|
-
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'))
|
6
|
-
end
|
7
|
-
|
8
|
-
assign_jobs = link_to(_("Configure Ansible Job"), "/ansible/hostgroups/#{hostgroup.id}", { class: 'la' })
|
9
|
-
|
10
|
-
actions = [
|
11
|
-
display_link_if_authorized(_('Nest'), hash_for_nest_hostgroup_path(:id => hostgroup)),
|
12
|
-
display_link_if_authorized(_('Clone'), hash_for_clone_hostgroup_path(:id => hostgroup))
|
13
|
-
]
|
14
|
-
actions.push play_roles if User.current.can?(:create_job_invocations)
|
15
|
-
actions.push assign_jobs if User.current.can?(:view_job_invocations) && User.current.can?(:view_recurring_logics)
|
16
|
-
actions.push display_delete_if_authorized(hash_for_hostgroup_path(:id => hostgroup).merge(:auth_object => hostgroup, :authorizer => authorizer), :data => { :confirm => warning_message(hostgroup) })
|
17
|
-
|
18
|
-
action_buttons(*actions)
|
19
|
-
%>
|