Skip to content

Commit

Permalink
Fixes #38084 - Add new REX job templates for bootc upgrade/switch/rol…
Browse files Browse the repository at this point in the history
…lback
  • Loading branch information
lfu committed Dec 19, 2024
1 parent 363db98 commit 3c7ae1f
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 1 deletion.
26 changes: 26 additions & 0 deletions app/views/foreman/job_templates/bootc_action.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<%#
kind: job_template
name: Bootc Action - Script Default
model: JobTemplate
job_category: Bootc
description_format: 'bootc %{action} %{options} %{target}'
provider_type: script
feature: katello_bootc_action
template_inputs:
- name: action
description: 'The bootc action: upgrade, switch, rollback or status'
input_type: user
options: "upgrade\nswitch\nrollback\nstatus"
required: true
- name: options
description: Additional options for bootc action
input_type: user
required: false
- name: target
description: Target for bootc switch action
input_type: user
required: false
%>

bootc <%= input('action') %> <%= input('options') %> <%= input('target') %>
subscription-manager facts --update
13 changes: 13 additions & 0 deletions app/views/foreman/job_templates/bootc_rollback.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%#
kind: job_template
name: Bootc Rollback - Script Default
job_category: Bootc
description_format: 'bootc rollback'
feature: katello_bootc_rollback
provider_type: script
foreign_input_sets:
- template: Bootc Action - Script Default
exclude: action, options, target
%>

<%= render_template('Bootc Action - Script Default', :action => 'rollback') %>
13 changes: 13 additions & 0 deletions app/views/foreman/job_templates/bootc_status.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%#
kind: job_template
name: Bootc Status - Script Default
job_category: Bootc
description_format: 'bootc status %{options}'
feature: katello_bootc_status
provider_type: script
foreign_input_sets:
- template: Bootc Action - Script Default
exclude: action, target
%>

<%= render_template('Bootc Action - Script Default', :action => 'status') %>
13 changes: 13 additions & 0 deletions app/views/foreman/job_templates/bootc_switch.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%#
kind: job_template
name: Bootc Switch - Script Default
job_category: Bootc
description_format: 'bootc switch %{options} %{target}'
feature: katello_bootc_switch
provider_type: script
foreign_input_sets:
- template: Bootc Action - Script Default
exclude: action
%>

<%= render_template('Bootc Action - Script Default', :action => 'switch') %>
13 changes: 13 additions & 0 deletions app/views/foreman/job_templates/bootc_upgrade.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%#
kind: job_template
name: Bootc Upgrade - Script Default
job_category: Bootc
description_format: 'bootc upgrade %{options}'
feature: katello_bootc_upgrade
provider_type: script
foreign_input_sets:
- template: Bootc Action - Script Default
exclude: action, target
%>

<%= render_template('Bootc Action - Script Default', :action => 'upgrade') %>
6 changes: 5 additions & 1 deletion db/seeds.d/75-job_templates.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
User.as_anonymous_admin do
JobTemplate.without_auditing do
# let's name root template as *_action.erb
root_action_files = Dir[File.join("#{Katello::Engine.root}/app/views/foreman/job_templates/**/*_action.erb")]
template_files = Dir[File.join("#{Katello::Engine.root}/app/views/foreman/job_templates/**/*.erb")]
template_files.reject! { |file| file.end_with?('_ansible_default.erb') } unless Katello.with_ansible?
template_files.each do |template|

# root templates need to be imported first
(root_action_files + (template_files - root_action_files)).each do |template|
sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
template = JobTemplate.import_raw!(File.read(template), :default => true, :lock => true, :update => sync)

Expand Down
4 changes: 4 additions & 0 deletions lib/katello/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ def katello_template_setting_values(name)
RemoteExecutionFeature.register(:katello_module_stream_action, N_("Katello: Module Stream Actions"),
:description => N_("Perform a module stream action via Katello interface"),
:provided_inputs => ['action', 'module_spec', 'options'])
RemoteExecutionFeature.register(:katello_bootc_upgrade, N_("Katello: Bootc Upgrade"), :description => N_("Bootc upgrade via Bootc interface"))
RemoteExecutionFeature.register(:katello_bootc_switch, N_("Katello: Bootc Switch"), :description => N_("Bootc switch via Bootc interface"))
RemoteExecutionFeature.register(:katello_bootc_rollback, N_("Katello: Bootc Rollback"), :description => N_("Bootc rollback via Bootc interface"))
RemoteExecutionFeature.register(:katello_bootc_status, N_("Katello: Bootc Status"), :description => N_("Bootc status via Bootc interface"))
allowed_template_helpers :errata

RemoteExecutionProvider.singleton_class.prepend(Katello::Concerns::RemoteExecutionProviderExtensions)
Expand Down

0 comments on commit 3c7ae1f

Please sign in to comment.