foreman_remote_execution 13.2.5 → 14.0.0

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: f9049b84ffeb17c5603ee539e395f8de3180211896386064769bdec137a55aa2
4
- data.tar.gz: 819932602c95357b78f56a1b04ed837c6f10ada81d653e0c621f832f594c6749
3
+ metadata.gz: 4399d9a8e85b8b79562fd8209acf25f2137887480607b465d0ab414b52bf11c8
4
+ data.tar.gz: c0f6b8be46eaf2cd537bd714338135ec86a6c21b11c9d544e15e26e164f11799
5
5
  SHA512:
6
- metadata.gz: bd6873c9f48b728cb4d7627c57bade8f1693355ef87d1ec2e7ece5af689fff10b2990edf8da0ae24a438afc0effab6de27be4db0c28908e340ea51dd1cc2bb4a
7
- data.tar.gz: 6f56b251e5678619ae91cc0627096a468c04f3c28ad87e0f76adb3978d213d75bf7889d71e4f1228810f52f25a913f6e026e3828f5b5f45d721bd588de0c566e
6
+ metadata.gz: a4f25bb7c8a1b2cee96fc4559f9d1184a35606a77ef027c353d95279f028298f42f4f03266a1b26dad18411303e0c08428a3072a242b1209f5191f1637c9ff7d
7
+ data.tar.gz: '0689a879588c08bd9c689d406ed02a3ccb3b1cba0d89cd54dbf76fff7965472ba4fb3d44d5f4afac5ede4a5f3c0663f53ba59dac59c4709c3021b19001db03da'
@@ -1,4 +1,4 @@
1
- class UiJobWizardController < Api::V2::BaseController
1
+ class UIJobWizardController < Api::V2::BaseController
2
2
  include FiltersHelper
3
3
  def categories
4
4
  job_categories = resource_scope(permission: action_permission)
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # macros to fetch information about invoked jobs
4
+ module ForemanRemoteExecution
5
+ module RendererMethods
6
+ extend ActiveSupport::Concern
7
+
8
+ def find_job_invocation_by_id(job_id, preload: nil)
9
+ JobInvocation.preload(preload).find_by(id: job_id)
10
+ rescue ActiveRecord::NotFound => _e
11
+ raise ::Foreman::Exception.new(N_("Can't find Job Invocation for an id %s"), job_id)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ Rails.autoloaders.each do |autoloader|
2
+ autoloader.inflector.inflect(
3
+ 'ssh_execution_provider' => 'SSHExecutionProvider',
4
+ 'remote_execution_ssh' => 'RemoteExecutionSSH'
5
+ )
6
+ end
@@ -26,15 +26,6 @@ module ForemanRemoteExecution
26
26
  end
27
27
  end
28
28
 
29
- # A workaround for https://projects.theforeman.org/issues/30685
30
- initializer 'foreman_remote_execution.rails_loading_workaround' do
31
- # Without this, in production environment the module gets prepended too
32
- # late and the extensions do not get applied
33
- # TODO: Remove this and from config.to_prepare once there is an extension
34
- # point in Foreman
35
- ProvisioningTemplatesHelper.prepend ForemanRemoteExecution::JobTemplatesExtensions
36
- end
37
-
38
29
  initializer 'foreman_remote_execution.apipie' do
39
30
  Apipie.configuration.checksum_path += ['/api/']
40
31
  end
@@ -45,257 +36,259 @@ module ForemanRemoteExecution
45
36
  ForemanTasks.dynflow.config.eager_load_paths << File.join(ForemanRemoteExecution::Engine.root, 'app/lib/actions')
46
37
  end
47
38
 
48
- initializer 'foreman_remote_execution.register_plugin', before: :finisher_hook do |_app|
49
- Foreman::Plugin.register :foreman_remote_execution do
50
- requires_foreman '>= 3.10'
51
- register_global_js_file 'global'
52
- register_gettext
53
-
54
- apipie_documented_controllers ["#{ForemanRemoteExecution::Engine.root}/app/controllers/api/v2/*.rb"]
55
- ApipieDSL.configuration.dsl_classes_matchers += [
56
- "#{ForemanRemoteExecution::Engine.root}/app/lib/foreman_remote_execution/renderer/**/*.rb",
57
- ]
58
- automatic_assets(false)
59
- precompile_assets(*assets_to_precompile)
60
-
61
- # Add settings to a Remote Execution category
62
- settings do
63
- category :remote_execution, N_('Remote Execution') do
64
- setting 'remote_execution_fallback_proxy',
65
- type: :boolean,
66
- description: N_('Search the host for any proxy with Remote Execution, useful when the host has no subnet or the subnet does not have an execution proxy'),
67
- default: false,
68
- full_name: N_('Fallback to Any Proxy')
69
- setting 'remote_execution_global_proxy',
70
- type: :boolean,
71
- description: N_('Search for remote execution proxy outside of the proxies assigned to the host. The search will be limited to the host\'s organization and location.'),
72
- default: true,
73
- full_name: N_('Enable Global Proxy')
74
- setting 'remote_execution_ssh_user',
75
- type: :string,
76
- description: N_('Default user to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_user.'),
77
- default: 'root',
78
- full_name: N_('SSH User')
79
- setting 'remote_execution_effective_user',
80
- type: :string,
81
- description: N_('Default user to use for executing the script. If the user differs from the SSH user, su or sudo is used to switch the user.'),
82
- default: 'root',
83
- full_name: N_('Effective User')
84
- setting 'remote_execution_effective_user_method',
85
- type: :string,
86
- description: N_('What command should be used to switch to the effective user. One of %s') % SSHExecutionProvider::EFFECTIVE_USER_METHODS.inspect,
87
- default: 'sudo',
88
- full_name: N_('Effective User Method'),
89
- collection: proc { Hash[SSHExecutionProvider::EFFECTIVE_USER_METHODS.map { |method| [method, method] }] }
90
- setting 'remote_execution_effective_user_password',
91
- type: :string,
92
- description: N_('Effective user password'),
93
- default: '',
94
- full_name: N_('Effective user password'),
95
- encrypted: true
96
- setting 'remote_execution_sync_templates',
97
- type: :boolean,
98
- description: N_('Whether we should sync templates from disk when running db:seed.'),
99
- default: true,
100
- full_name: N_('Sync Job Templates')
101
- setting 'remote_execution_ssh_port',
102
- type: :integer,
103
- description: N_('Port to use for SSH communication. Default port 22. You may override per host by setting a parameter called remote_execution_ssh_port.'),
104
- default: 22,
105
- full_name: N_('SSH Port')
106
- setting 'remote_execution_connect_by_ip',
107
- type: :boolean,
108
- description: N_('Should the ip addresses on host interfaces be preferred over the fqdn? '\
109
- 'It is useful when DNS not resolving the fqdns properly. You may override this per host by setting a parameter called remote_execution_connect_by_ip. '\
110
- 'For dual-stacked hosts you should consider the remote_execution_connect_by_ip_prefer_ipv6 setting'),
111
- default: false,
112
- full_name: N_('Connect by IP')
113
- setting 'remote_execution_connect_by_ip_prefer_ipv6',
114
- type: :boolean,
115
- description: N_('When connecting using ip address, should the IPv6 addresses be preferred? '\
116
- 'If no IPv6 address is set, it falls back to IPv4 automatically. You may override this per host by setting a parameter called remote_execution_connect_by_ip_prefer_ipv6. '\
117
- 'By default and for compatibility, IPv4 will be preferred over IPv6 by default'),
118
- default: false,
119
- full_name: N_('Prefer IPv6 over IPv4')
120
- setting 'remote_execution_ssh_password',
121
- type: :string,
122
- description: N_('Default password to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_password'),
123
- default: nil,
124
- full_name: N_('Default SSH password'),
125
- encrypted: true
126
- setting 'remote_execution_ssh_key_passphrase',
127
- type: :string,
128
- description: N_('Default key passphrase to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_key_passphrase'),
129
- default: nil,
130
- full_name: N_('Default SSH key passphrase'),
131
- encrypted: true
132
- setting 'remote_execution_workers_pool_size',
133
- type: :integer,
134
- description: N_('Amount of workers in the pool to handle the execution of the remote execution jobs. Restart of the dynflowd/foreman-tasks service is required.'),
135
- default: 5,
136
- full_name: N_('Workers pool size')
137
- setting 'remote_execution_cleanup_working_dirs',
138
- type: :boolean,
139
- description: N_('When enabled, working directories will be removed after task completion. You may override this per host by setting a parameter called remote_execution_cleanup_working_dirs.'),
140
- default: true,
141
- full_name: N_('Cleanup working directories')
142
- setting 'remote_execution_cockpit_url',
143
- type: :string,
144
- description: N_('Where to find the Cockpit instance for the Web Console button. By default, no button is shown.'),
145
- default: nil,
146
- full_name: N_('Cockpit URL')
147
- setting 'remote_execution_form_job_template',
148
- type: :string,
149
- description: N_('Choose a job template that is pre-selected in job invocation form'),
150
- default: 'Run Command - Script Default',
151
- full_name: N_('Form Job Template'),
152
- collection: proc { Hash[JobTemplate.unscoped.map { |template| [template.name, template.name] }] }
153
- setting 'remote_execution_job_invocation_report_template',
154
- type: :string,
155
- description: N_('Select a report template used for generating a report for a particular remote execution job'),
156
- default: 'Job - Invocation Report',
157
- full_name: N_('Job Invocation Report Template'),
158
- collection: proc { ForemanRemoteExecution.job_invocation_report_templates_select }
159
- setting 'remote_execution_time_to_pickup',
160
- type: :integer,
161
- description: N_('Time in seconds within which the host has to pick up a job. If the job is not picked up within this limit, the job will be cancelled. Defaults to 1 day. Applies only to pull-mqtt based jobs.'),
162
- default: 24 * 60 * 60,
163
- full_name: N_('Time to pickup')
39
+ initializer 'foreman_remote_execution.register_plugin', before: :finisher_hook do |app|
40
+ app.reloader.to_prepare do
41
+ Foreman::Plugin.register :foreman_remote_execution do
42
+ requires_foreman '>= 3.13'
43
+ register_global_js_file 'global'
44
+ register_gettext
45
+
46
+ apipie_documented_controllers ["#{ForemanRemoteExecution::Engine.root}/app/controllers/api/v2/*.rb"]
47
+ ApipieDSL.configuration.dsl_classes_matchers += [
48
+ "#{ForemanRemoteExecution::Engine.root}/app/lib/foreman_remote_execution/renderer/**/*.rb",
49
+ ]
50
+ automatic_assets(false)
51
+ precompile_assets(*assets_to_precompile)
52
+
53
+ # Add settings to a Remote Execution category
54
+ settings do
55
+ category :remote_execution, N_('Remote Execution') do
56
+ setting 'remote_execution_fallback_proxy',
57
+ type: :boolean,
58
+ description: N_('Search the host for any proxy with Remote Execution, useful when the host has no subnet or the subnet does not have an execution proxy'),
59
+ default: false,
60
+ full_name: N_('Fallback to Any Proxy')
61
+ setting 'remote_execution_global_proxy',
62
+ type: :boolean,
63
+ description: N_('Search for remote execution proxy outside of the proxies assigned to the host. The search will be limited to the host\'s organization and location.'),
64
+ default: true,
65
+ full_name: N_('Enable Global Proxy')
66
+ setting 'remote_execution_ssh_user',
67
+ type: :string,
68
+ description: N_('Default user to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_user.'),
69
+ default: 'root',
70
+ full_name: N_('SSH User')
71
+ setting 'remote_execution_effective_user',
72
+ type: :string,
73
+ description: N_('Default user to use for executing the script. If the user differs from the SSH user, su or sudo is used to switch the user.'),
74
+ default: 'root',
75
+ full_name: N_('Effective User')
76
+ setting 'remote_execution_effective_user_method',
77
+ type: :string,
78
+ description: N_('What command should be used to switch to the effective user. One of %s') % ::SSHExecutionProvider::EFFECTIVE_USER_METHODS.inspect,
79
+ default: 'sudo',
80
+ full_name: N_('Effective User Method'),
81
+ collection: proc { Hash[::SSHExecutionProvider::EFFECTIVE_USER_METHODS.map { |method| [method, method] }] }
82
+ setting 'remote_execution_effective_user_password',
83
+ type: :string,
84
+ description: N_('Effective user password'),
85
+ default: '',
86
+ full_name: N_('Effective user password'),
87
+ encrypted: true
88
+ setting 'remote_execution_sync_templates',
89
+ type: :boolean,
90
+ description: N_('Whether we should sync templates from disk when running db:seed.'),
91
+ default: true,
92
+ full_name: N_('Sync Job Templates')
93
+ setting 'remote_execution_ssh_port',
94
+ type: :integer,
95
+ description: N_('Port to use for SSH communication. Default port 22. You may override per host by setting a parameter called remote_execution_ssh_port.'),
96
+ default: 22,
97
+ full_name: N_('SSH Port')
98
+ setting 'remote_execution_connect_by_ip',
99
+ type: :boolean,
100
+ description: N_('Should the ip addresses on host interfaces be preferred over the fqdn? '\
101
+ 'It is useful when DNS not resolving the fqdns properly. You may override this per host by setting a parameter called remote_execution_connect_by_ip. '\
102
+ 'For dual-stacked hosts you should consider the remote_execution_connect_by_ip_prefer_ipv6 setting'),
103
+ default: false,
104
+ full_name: N_('Connect by IP')
105
+ setting 'remote_execution_connect_by_ip_prefer_ipv6',
106
+ type: :boolean,
107
+ description: N_('When connecting using ip address, should the IPv6 addresses be preferred? '\
108
+ 'If no IPv6 address is set, it falls back to IPv4 automatically. You may override this per host by setting a parameter called remote_execution_connect_by_ip_prefer_ipv6. '\
109
+ 'By default and for compatibility, IPv4 will be preferred over IPv6 by default'),
110
+ default: false,
111
+ full_name: N_('Prefer IPv6 over IPv4')
112
+ setting 'remote_execution_ssh_password',
113
+ type: :string,
114
+ description: N_('Default password to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_password'),
115
+ default: nil,
116
+ full_name: N_('Default SSH password'),
117
+ encrypted: true
118
+ setting 'remote_execution_ssh_key_passphrase',
119
+ type: :string,
120
+ description: N_('Default key passphrase to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_key_passphrase'),
121
+ default: nil,
122
+ full_name: N_('Default SSH key passphrase'),
123
+ encrypted: true
124
+ setting 'remote_execution_workers_pool_size',
125
+ type: :integer,
126
+ description: N_('Amount of workers in the pool to handle the execution of the remote execution jobs. Restart of the dynflowd/foreman-tasks service is required.'),
127
+ default: 5,
128
+ full_name: N_('Workers pool size')
129
+ setting 'remote_execution_cleanup_working_dirs',
130
+ type: :boolean,
131
+ description: N_('When enabled, working directories will be removed after task completion. You may override this per host by setting a parameter called remote_execution_cleanup_working_dirs.'),
132
+ default: true,
133
+ full_name: N_('Cleanup working directories')
134
+ setting 'remote_execution_cockpit_url',
135
+ type: :string,
136
+ description: N_('Where to find the Cockpit instance for the Web Console button. By default, no button is shown.'),
137
+ default: nil,
138
+ full_name: N_('Cockpit URL')
139
+ setting 'remote_execution_form_job_template',
140
+ type: :string,
141
+ description: N_('Choose a job template that is pre-selected in job invocation form'),
142
+ default: 'Run Command - Script Default',
143
+ full_name: N_('Form Job Template'),
144
+ collection: proc { Hash[JobTemplate.unscoped.map { |template| [template.name, template.name] }] }
145
+ setting 'remote_execution_job_invocation_report_template',
146
+ type: :string,
147
+ description: N_('Select a report template used for generating a report for a particular remote execution job'),
148
+ default: 'Job - Invocation Report',
149
+ full_name: N_('Job Invocation Report Template'),
150
+ collection: proc { ForemanRemoteExecution.job_invocation_report_templates_select }
151
+ setting 'remote_execution_time_to_pickup',
152
+ type: :integer,
153
+ description: N_('Time in seconds within which the host has to pick up a job. If the job is not picked up within this limit, the job will be cancelled. Defaults to 1 day. Applies only to pull-mqtt based jobs.'),
154
+ default: 24 * 60 * 60,
155
+ full_name: N_('Time to pickup')
156
+ end
164
157
  end
165
- end
166
158
 
167
- # Add permissions
168
- security_block :foreman_remote_execution do
169
- permission :view_job_templates, { :job_templates => [:index, :show, :revision, :auto_complete_search, :auto_complete_job_category, :preview, :export],
170
- :'api/v2/job_templates' => [:index, :show, :revision, :export],
171
- :'api/v2/template_inputs' => [:index, :show],
172
- :'api/v2/foreign_input_sets' => [:index, :show],
173
- :ui_job_wizard => [:categories, :template, :resources, :job_invocation]}, :resource_type => 'JobTemplate'
174
- permission :create_job_templates, { :job_templates => [:new, :create, :clone_template, :import],
175
- :'api/v2/job_templates' => [:create, :clone, :import] }, :resource_type => 'JobTemplate'
176
- permission :edit_job_templates, { :job_templates => [:edit, :update],
177
- :'api/v2/job_templates' => [:update],
178
- :'api/v2/template_inputs' => [:create, :update, :destroy],
179
- :'api/v2/foreign_input_sets' => [:create, :update, :destroy]}, :resource_type => 'JobTemplate'
180
- permission :view_remote_execution_features, { :remote_execution_features => [:index, :show],
181
- :'api/v2/remote_execution_features' => [:index, :show, :available_remote_execution_features]},
182
- :resource_type => 'RemoteExecutionFeature'
183
- permission :edit_remote_execution_features, { :remote_execution_features => [:update],
184
- :'api/v2/remote_execution_features' => [:update ]}, :resource_type => 'RemoteExecutionFeature'
185
- permission :destroy_job_templates, { :job_templates => [:destroy],
186
- :'api/v2/job_templates' => [:destroy] }, :resource_type => 'JobTemplate'
187
- permission :lock_job_templates, { :job_templates => [:lock, :unlock] }, :resource_type => 'JobTemplate'
188
- permission :create_job_invocations, { :job_invocations => [:new, :create, :legacy_create, :refresh, :rerun, :preview_hosts],
189
- 'api/v2/job_invocations' => [:create, :rerun] }, :resource_type => 'JobInvocation'
190
- permission :view_job_invocations, { :job_invocations => [:index, :chart, :show, :auto_complete_search, :preview_job_invocations_per_host], :template_invocations => [:show],
191
- 'api/v2/job_invocations' => [:index, :show, :output, :raw_output, :outputs] }, :resource_type => 'JobInvocation'
192
- permission :view_template_invocations, { :template_invocations => [:show],
193
- 'api/v2/template_invocations' => [:template_invocations], :ui_job_wizard => [:job_invocation] }, :resource_type => 'TemplateInvocation'
194
- permission :create_template_invocations, {}, :resource_type => 'TemplateInvocation'
195
- permission :execute_jobs_on_infrastructure_hosts, {}, :resource_type => 'JobInvocation'
196
- permission :cancel_job_invocations, { :job_invocations => [:cancel], 'api/v2/job_invocations' => [:cancel] }, :resource_type => 'JobInvocation'
197
- # this permissions grants user to get auto completion hints when setting up filters
198
- permission :filter_autocompletion_for_template_invocation, { :template_invocations => [ :auto_complete_search, :index ] },
199
- :resource_type => 'TemplateInvocation'
200
- permission :cockpit_hosts, { 'cockpit' => [:redirect, :host_ssh_params] }, :resource_type => 'Host'
201
- end
159
+ # Add permissions
160
+ security_block :foreman_remote_execution do
161
+ permission :view_job_templates, { :job_templates => [:index, :show, :revision, :auto_complete_search, :auto_complete_job_category, :preview, :export],
162
+ :'api/v2/job_templates' => [:index, :show, :revision, :export],
163
+ :'api/v2/template_inputs' => [:index, :show],
164
+ :'api/v2/foreign_input_sets' => [:index, :show],
165
+ :ui_job_wizard => [:categories, :template, :resources, :job_invocation]}, :resource_type => 'JobTemplate'
166
+ permission :create_job_templates, { :job_templates => [:new, :create, :clone_template, :import],
167
+ :'api/v2/job_templates' => [:create, :clone, :import] }, :resource_type => 'JobTemplate'
168
+ permission :edit_job_templates, { :job_templates => [:edit, :update],
169
+ :'api/v2/job_templates' => [:update],
170
+ :'api/v2/template_inputs' => [:create, :update, :destroy],
171
+ :'api/v2/foreign_input_sets' => [:create, :update, :destroy]}, :resource_type => 'JobTemplate'
172
+ permission :view_remote_execution_features, { :remote_execution_features => [:index, :show],
173
+ :'api/v2/remote_execution_features' => [:index, :show, :available_remote_execution_features]},
174
+ :resource_type => 'RemoteExecutionFeature'
175
+ permission :edit_remote_execution_features, { :remote_execution_features => [:update],
176
+ :'api/v2/remote_execution_features' => [:update ]}, :resource_type => 'RemoteExecutionFeature'
177
+ permission :destroy_job_templates, { :job_templates => [:destroy],
178
+ :'api/v2/job_templates' => [:destroy] }, :resource_type => 'JobTemplate'
179
+ permission :lock_job_templates, { :job_templates => [:lock, :unlock] }, :resource_type => 'JobTemplate'
180
+ permission :create_job_invocations, { :job_invocations => [:new, :create, :legacy_create, :refresh, :rerun, :preview_hosts],
181
+ 'api/v2/job_invocations' => [:create, :rerun] }, :resource_type => 'JobInvocation'
182
+ permission :view_job_invocations, { :job_invocations => [:index, :chart, :show, :auto_complete_search, :preview_job_invocations_per_host], :template_invocations => [:show],
183
+ 'api/v2/job_invocations' => [:index, :show, :output, :raw_output, :outputs] }, :resource_type => 'JobInvocation'
184
+ permission :view_template_invocations, { :template_invocations => [:show],
185
+ 'api/v2/template_invocations' => [:template_invocations], :ui_job_wizard => [:job_invocation] }, :resource_type => 'TemplateInvocation'
186
+ permission :create_template_invocations, {}, :resource_type => 'TemplateInvocation'
187
+ permission :execute_jobs_on_infrastructure_hosts, {}, :resource_type => 'JobInvocation'
188
+ permission :cancel_job_invocations, { :job_invocations => [:cancel], 'api/v2/job_invocations' => [:cancel] }, :resource_type => 'JobInvocation'
189
+ # this permissions grants user to get auto completion hints when setting up filters
190
+ permission :filter_autocompletion_for_template_invocation, { :template_invocations => [ :auto_complete_search, :index ] },
191
+ :resource_type => 'TemplateInvocation'
192
+ permission :cockpit_hosts, { 'cockpit' => [:redirect, :host_ssh_params] }, :resource_type => 'Host'
193
+ end
202
194
 
203
- USER_PERMISSIONS = [
204
- :view_job_templates,
205
- :view_job_invocations,
206
- :create_job_invocations,
207
- :create_template_invocations,
208
- :view_hosts,
209
- :view_smart_proxies,
210
- :view_remote_execution_features,
211
- ].freeze
212
- MANAGER_PERMISSIONS = USER_PERMISSIONS + [
213
- :cancel_job_invocations,
214
- :destroy_job_templates,
215
- :edit_job_templates,
216
- :create_job_templates,
217
- :lock_job_templates,
218
- :view_audit_logs,
219
- :filter_autocompletion_for_template_invocation,
220
- :edit_remote_execution_features,
221
- ]
222
-
223
- # Add a new role called 'Remote Execution User ' if it doesn't exist
224
- role 'Remote Execution User', USER_PERMISSIONS, 'Role with permissions to run remote execution jobs against hosts'
225
- role 'Remote Execution Manager', MANAGER_PERMISSIONS, 'Role with permissions to manage job templates, remote execution features, cancel jobs and view audit logs'
226
-
227
- add_all_permissions_to_default_roles(except: [:execute_jobs_on_infrastructure_hosts])
228
- add_permissions_to_default_roles({
229
- Role::MANAGER => [:execute_jobs_on_infrastructure_hosts],
230
- Role::SITE_MANAGER => USER_PERMISSIONS + [:execute_jobs_on_infrastructure_hosts],
231
- })
232
-
233
- # add menu entry
234
- menu :top_menu, :job_templates,
235
- url_hash: { controller: :job_templates, action: :index },
236
- caption: N_('Job templates'),
237
- parent: :hosts_menu,
238
- after: :provisioning_templates
239
- menu :admin_menu, :remote_execution_features,
240
- url_hash: { controller: :remote_execution_features, action: :index },
241
- caption: N_('Remote Execution Features'),
242
- parent: :administer_menu,
243
- after: :bookmarks
244
-
245
- menu :top_menu, :job_invocations,
246
- url_hash: { controller: :job_invocations, action: :index },
247
- caption: N_('Jobs'),
248
- parent: :monitor_menu,
249
- after: :audits
250
-
251
- menu :labs_menu, :job_invocations_detail,
252
- url_hash: { controller: :job_invocations, action: :show },
253
- caption: N_('Job invocations detail'),
254
- parent: :lab_features_menu,
255
- url: '/experimental/job_invocations_detail/1'
256
-
257
- register_custom_status HostStatus::ExecutionStatus
258
- # add dashboard widget
259
- # widget 'foreman_remote_execution_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
260
- widget 'dashboard/latest-jobs', :name => N_('Latest Jobs'), :sizex => 6, :sizey => 1
261
-
262
- parameter_filter Subnet, :remote_execution_proxies, :remote_execution_proxy_ids => []
263
- parameter_filter Nic::Interface do |ctx|
264
- ctx.permit :execution
265
- end
195
+ USER_PERMISSIONS = [
196
+ :view_job_templates,
197
+ :view_job_invocations,
198
+ :create_job_invocations,
199
+ :create_template_invocations,
200
+ :view_hosts,
201
+ :view_smart_proxies,
202
+ :view_remote_execution_features,
203
+ ].freeze
204
+ MANAGER_PERMISSIONS = USER_PERMISSIONS + [
205
+ :cancel_job_invocations,
206
+ :destroy_job_templates,
207
+ :edit_job_templates,
208
+ :create_job_templates,
209
+ :lock_job_templates,
210
+ :view_audit_logs,
211
+ :filter_autocompletion_for_template_invocation,
212
+ :edit_remote_execution_features,
213
+ ]
214
+
215
+ # Add a new role called 'Remote Execution User ' if it doesn't exist
216
+ role 'Remote Execution User', USER_PERMISSIONS, 'Role with permissions to run remote execution jobs against hosts'
217
+ role 'Remote Execution Manager', MANAGER_PERMISSIONS, 'Role with permissions to manage job templates, remote execution features, cancel jobs and view audit logs'
218
+
219
+ add_all_permissions_to_default_roles(except: [:execute_jobs_on_infrastructure_hosts])
220
+ add_permissions_to_default_roles({
221
+ Role::MANAGER => [:execute_jobs_on_infrastructure_hosts],
222
+ Role::SITE_MANAGER => USER_PERMISSIONS + [:execute_jobs_on_infrastructure_hosts],
223
+ })
224
+
225
+ # add menu entry
226
+ menu :top_menu, :job_templates,
227
+ url_hash: { controller: :job_templates, action: :index },
228
+ caption: N_('Job templates'),
229
+ parent: :hosts_menu,
230
+ after: :provisioning_templates
231
+ menu :admin_menu, :remote_execution_features,
232
+ url_hash: { controller: :remote_execution_features, action: :index },
233
+ caption: N_('Remote Execution Features'),
234
+ parent: :administer_menu,
235
+ after: :bookmarks
236
+
237
+ menu :top_menu, :job_invocations,
238
+ url_hash: { controller: :job_invocations, action: :index },
239
+ caption: N_('Jobs'),
240
+ parent: :monitor_menu,
241
+ after: :audits
242
+
243
+ menu :labs_menu, :job_invocations_detail,
244
+ url_hash: { controller: :job_invocations, action: :show },
245
+ caption: N_('Job invocations detail'),
246
+ parent: :lab_features_menu,
247
+ url: '/experimental/job_invocations_detail/1'
248
+
249
+ register_custom_status HostStatus::ExecutionStatus
250
+ # add dashboard widget
251
+ # widget 'foreman_remote_execution_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
252
+ widget 'dashboard/latest-jobs', :name => N_('Latest Jobs'), :sizex => 6, :sizey => 1
253
+
254
+ parameter_filter Subnet, :remote_execution_proxies, :remote_execution_proxy_ids => []
255
+ parameter_filter Nic::Interface do |ctx|
256
+ ctx.permit :execution
257
+ end
266
258
 
267
- register_graphql_query_field :job_invocations, '::Types::JobInvocation', :collection_field
268
- register_graphql_query_field :job_invocation, '::Types::JobInvocation', :record_field
259
+ register_graphql_query_field :job_invocations, '::Types::JobInvocation', :collection_field
260
+ register_graphql_query_field :job_invocation, '::Types::JobInvocation', :record_field
269
261
 
270
- register_graphql_mutation_field :create_job_invocation, ::Mutations::JobInvocations::Create
262
+ register_graphql_mutation_field :create_job_invocation, ::Mutations::JobInvocations::Create
271
263
 
272
- extend_template_helpers ForemanRemoteExecution::RendererMethods
264
+ extend_template_helpers ForemanRemoteExecution::RendererMethods
273
265
 
274
- extend_rabl_template 'api/v2/smart_proxies/main', 'api/v2/smart_proxies/pubkey'
275
- extend_rabl_template 'api/v2/interfaces/main', 'api/v2/interfaces/execution_flag'
276
- extend_rabl_template 'api/v2/subnets/show', 'api/v2/subnets/remote_execution_proxies'
277
- extend_rabl_template 'api/v2/hosts/main', 'api/v2/host/main'
278
- parameter_filter ::Subnet, :remote_execution_proxy_ids
266
+ extend_rabl_template 'api/v2/smart_proxies/main', 'api/v2/smart_proxies/pubkey'
267
+ extend_rabl_template 'api/v2/interfaces/main', 'api/v2/interfaces/execution_flag'
268
+ extend_rabl_template 'api/v2/subnets/show', 'api/v2/subnets/remote_execution_proxies'
269
+ extend_rabl_template 'api/v2/hosts/main', 'api/v2/host/main'
270
+ parameter_filter ::Subnet, :remote_execution_proxy_ids
279
271
 
280
- describe_host do
281
- multiple_actions_provider :rex_hosts_multiple_actions
282
- overview_buttons_provider :rex_host_overview_buttons
283
- end
272
+ describe_host do
273
+ multiple_actions_provider :rex_hosts_multiple_actions
274
+ overview_buttons_provider :rex_host_overview_buttons
275
+ end
284
276
 
285
- # Extend Registration module
286
- extend_allowed_registration_vars :remote_execution_interface
287
- extend_allowed_registration_vars :setup_remote_execution_pull
288
- ForemanTasks.dynflow.eager_load_actions!
289
- extend_observable_events(
290
- ::Dynflow::Action.descendants.select do |klass|
291
- klass <= ::Actions::ObservableAction
292
- end.map(&:namespaced_event_names) +
293
- RemoteExecutionFeature.all.pluck(:label).flat_map do |label|
294
- [::Actions::RemoteExecution::RunHostJob, ::Actions::RemoteExecution::RunHostsJob].map do |klass|
295
- klass.feature_job_event_names(label)
277
+ # Extend Registration module
278
+ extend_allowed_registration_vars :remote_execution_interface
279
+ extend_allowed_registration_vars :setup_remote_execution_pull
280
+ ForemanTasks.dynflow.eager_load_actions!
281
+ extend_observable_events(
282
+ ::Dynflow::Action.descendants.select do |klass|
283
+ klass <= ::Actions::ObservableAction
284
+ end.map(&:namespaced_event_names) +
285
+ RemoteExecutionFeature.all.pluck(:label).flat_map do |label|
286
+ [::Actions::RemoteExecution::RunHostJob, ::Actions::RemoteExecution::RunHostsJob].map do |klass|
287
+ klass.feature_job_event_names(label)
288
+ end
296
289
  end
297
- end
298
- )
290
+ )
291
+ end
299
292
  end
300
293
  end
301
294
 
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '13.2.5'.freeze
2
+ VERSION = '14.0.0'.freeze
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- class UiJobWizardControllerTest < ActionController::TestCase
3
+ class UIJobWizardControllerTest < ActionController::TestCase
4
4
  def setup
5
5
  FactoryBot.create(:job_template, :job_category => 'cat1')
6
6
  FactoryBot.create(:job_template, :job_category => 'cat2')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.2.5
4
+ version: 14.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-27 00:00:00.000000000 Z
11
+ date: 2024-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -170,6 +170,7 @@ files:
170
170
  - app/lib/actions/remote_execution/template_invocation_progress_logging.rb
171
171
  - app/lib/foreman_remote_execution/provider_input.rb
172
172
  - app/lib/foreman_remote_execution/renderer/scope/input.rb
173
+ - app/lib/foreman_remote_execution/renderer_methods.rb
173
174
  - app/lib/proxy_api/remote_execution_ssh.rb
174
175
  - app/mailers/.gitkeep
175
176
  - app/mailers/rex_job_mailer.rb
@@ -213,7 +214,6 @@ files:
213
214
  - app/overrides/subnet_proxies.rb
214
215
  - app/services/default_proxy_proxy_selector.rb
215
216
  - app/services/remote_execution_proxy_selector.rb
216
- - app/services/renderer_methods.rb
217
217
  - app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
218
218
  - app/views/api/v2/foreign_input_sets/base.json.rabl
219
219
  - app/views/api/v2/foreign_input_sets/create.json.rabl
@@ -297,6 +297,7 @@ files:
297
297
  - app/views/templates/script/run_command.erb
298
298
  - app/views/templates/script/run_downloaded_script.erb
299
299
  - app/views/templates/script/service_action.erb
300
+ - config/initializers/inflections.rb
300
301
  - config/routes.rb
301
302
  - db/migrate/20150612121541_add_job_template_to_template.rb
302
303
  - db/migrate/20150708133241_add_targeting.rb
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # macros to fetch information about invoked jobs
4
- module RendererMethods
5
- extend ActiveSupport::Concern
6
-
7
- def find_job_invocation_by_id(job_id, preload: nil)
8
- JobInvocation.preload(preload).find_by(id: job_id)
9
- rescue ActiveRecord::NotFound => _e
10
- raise ::Foreman::Exception.new(N_("Can't find Job Invocation for an id %s"), job_id)
11
- end
12
- end