-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #37051 - Add job templates for Ansible 'by search query' (#10850)
- Loading branch information
1 parent
f281fc5
commit 4f236c7
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
app/views/foreman/job_templates/install_errata_by_search_query_-_katello_ansible_default.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(' ')}") %> | ||
<% else -%> | ||
<% advisories = advisory_ids.map { |e| "--advisory=#{e}" }.join(' ') -%> | ||
<%= render_template('Run Command - Ansible Default', :command => "yum -y update-minimal #{advisories}") %> | ||
<% end -%> |
28 changes: 28 additions & 0 deletions
28
...iews/foreman/job_templates/install_packages_by_search_query_-_katello_ansible_default.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -%> | ||
|
26 changes: 26 additions & 0 deletions
26
...views/foreman/job_templates/remove_packages_by_search_query_-_katello_ansible_default.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
33 changes: 33 additions & 0 deletions
33
...views/foreman/job_templates/update_packages_by_search_query_-_katello_ansible_default.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -%> |