Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37051 - Add Katello Ansible default job templates #10850

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<%#
kind: job_template
name: Install errata by search query - Katello Ansible Default
job_category: Katello
description_format: 'Install errata %{Errata search query}'
feature: katello_errata_install_by_search
provider_type: Ansible
template_inputs:
- name: Errata search query
description: Filter criteria for errata to be installed.
input_type: user
required: false
%>

<% advisory_ids = @host.advisory_ids(search: input("Errata search query")) -%>
<% render_error(N_("No errata matching given search query")) if !input("Errata search query").blank? && advisory_ids.blank? -%>
# RESOLVED_ERRATA_IDS=<%= advisory_ids.join(',') %>

<% if @host.operatingsystem.family == 'Suse' -%>
<%= render_template('Run Command - Ansible Default', :command => "zypper -n install -t patch #{advisory_ids.join(' ')}") %>
jeremylenz marked this conversation as resolved.
Show resolved Hide resolved
<% else -%>
<% advisories = advisory_ids.map { |e| "--advisory=#{e}" }.join(' ') -%>
<%= render_template('Run Command - Ansible Default', :command => "yum -y update-minimal #{advisories}") %>
jeremylenz marked this conversation as resolved.
Show resolved Hide resolved
<% end -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<%#
kind: job_template
name: Install packages by search query - Katello Ansible Default
job_category: Katello
description_format: 'Install package(s) %{Package search query}'
feature: katello_package_install_by_search
provider_type: Ansible
template_inputs:
- name: Package search query
description: Filter criteria for packages to be installed. IMPORTANT- If left blank, the job will attempt to install all possible packages.
input_type: user
required: false
%>
<% package_names = @host.package_names_for_job_template(
action: 'install',
search: input('Package search query')
) -%>
---
- hosts: all
tasks:
- package:
<% if package_names.empty? -%>
name: []
<% else -%>
name: <%= indent(10) { to_yaml(package_names).gsub(/---/, "") } -%>
state: present
<% end -%>

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<%#
kind: job_template
name: Remove packages by search query - Katello Ansible Default
job_category: Katello
description_format: 'Remove package(s) %{Packages search query}'
feature: katello_package_remove_by_search
provider_type: Ansible
template_inputs:
- name: Packages search query
description: Filter criteria for packages to be removed.
input_type: user
required: false
%>
<% package_names = @host.package_names_for_job_template(
action: 'remove',
search: input('Packages search query')
) -%>
---
- hosts: all
tasks:
- package:
name:
<% package_names.each do |package_name| -%>
- <%= package_name %>
<% end -%>
state: absent
jeremylenz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<%#
kind: job_template
name: Update packages by search query - Katello Ansible Default
job_category: Katello
description_format: 'Update package(s) %{Packages search query}'
feature: katello_package_remove_by_search
provider_type: Ansible
template_inputs:
- name: Packages search query
description: Filter criteria for packages to be updated.
input_type: user
required: false
- name: Selected update versions
description: JSON string of selected package versions to be updated, in the format [ nvra ]. Leave blank to upgrade to latest available version.
input_type: user
required: false
value_type: plain
%>
<% package_names = @host.package_names_for_job_template(
action: 'update',
search: input('Packages search query'),
versions: input('Selected update versions')
) -%>
<% if package_names.empty? -%>
<%= render_template('Run Command - Ansible Default', :command => "yum -y update") %>
<% else -%>
---
- hosts: all
tasks:
- package:
name: <%= indent(10) { to_yaml(package_names).gsub(/---/, "") } -%>
state: latest
<% end -%>
Loading