This repository has been archived by the owner on Jul 9, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #24425 - Templates for modularity actions
This commit contains rex templates for modularity related actions.
- Loading branch information
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
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,50 @@ | ||
<%# | ||
kind: job_template | ||
name: Module Action - Ansible Default | ||
model: JobTemplate | ||
job_category: Modules | ||
description_format: "Module %{action} %{module_spec}" | ||
provider_type: Ansible | ||
template_inputs: | ||
- name: pre_script | ||
description: A script to run prior to the module action | ||
input_type: user | ||
required: false | ||
advanced: true | ||
- name: action | ||
description: 'The module action: enable, disable, install, update, or remove, lock, unlock' | ||
input_type: user | ||
required: true | ||
options: "\nlist\ninfo\nenable\ndisable\ninstall\nupdate\nremove\nprovides\nlock\nunlock\nprofile\nstreams" | ||
- name: module_spec | ||
description: The module specification. module:stream/profile | ||
input_type: user | ||
required: false | ||
- name: options | ||
description: Other optional flags for the action | ||
input_type: user | ||
required: false | ||
- name: post_script | ||
description: A script to run after the module action | ||
input_type: user | ||
required: false | ||
advanced: true | ||
%> | ||
<% command = "dnf -y module #{input(:action)} #{input(:module_spec)} #{input(:options)}" %> | ||
|
||
--- | ||
- hosts: all | ||
<%- if input('pre_script').present? -%> | ||
pre_tasks: | ||
- shell: "<%= input('pre_script') %>" | ||
<%- end -%> | ||
tasks: | ||
- shell: | | ||
<%= indent(8) { command } %> | ||
register: out | ||
- debug: var=out | ||
<%- if input('post_script').present? -%> | ||
post_tasks: | ||
- shell: "<%= input('post_script') %>" | ||
<%- end -%> |
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,67 @@ | ||
<%# | ||
kind: job_template | ||
name: Module Action - SSH Default | ||
model: JobTemplate | ||
job_category: Modules | ||
description_format: "%{action} %{module_spec}" | ||
provider_type: Ansible | ||
template_inputs: | ||
- name: pre_script | ||
description: A script to run prior to the module action | ||
input_type: user | ||
required: false | ||
advanced: true | ||
- name: action | ||
description: 'The module action: enable, disable, install, update, or remove, lock, unlock' | ||
input_type: user | ||
required: true | ||
options: "\nlist\ninfo\nenable\ndisable\ninstall\nupdate\nremove\nprovides\nlock\nunlock\nprofile\nstreams" | ||
- name: module_spec | ||
description: The module specification. module:stream/profile | ||
input_type: user | ||
required: false | ||
- name: options | ||
description: Other optional flags for the action | ||
input_type: user | ||
required: false | ||
- name: post_script | ||
description: A script to run after the module action | ||
input_type: user | ||
required: false | ||
advanced: true | ||
%> | ||
<% | ||
supported_families = ['Redhat'] | ||
render_error(N_('Unsupported or no operating system found for this host.')) unless @host.operatingsystem && supported_families.include?(@host.operatingsystem.family) | ||
-%> | ||
#!/bin/bash | ||
|
||
# Helper function that exits with a particular message and code. | ||
# | ||
# Usage: | ||
# exit_with_message "Could not do a thing" 2 | ||
# | ||
function exit_with_message { | ||
echo "${1}, exiting..." | ||
exit $2 | ||
} | ||
|
||
<% unless input("pre_script").blank? -%> | ||
# Pre Script | ||
<%= input("pre_script") %> | ||
RETVAL=$? | ||
[ $RETVAL -eq 0 ] || exit_with_message "Pre script failed" $RETVAL | ||
<% end -%> | ||
|
||
# Action | ||
dnf -y module <%= input("action") %> <%= input("module_spec") %> <%= input("options") %> | ||
RETVAL=$? | ||
[ $RETVAL -eq 0 ] || exit_with_message " module action failed" $RETVAL | ||
|
||
<% unless input("post_script").blank? -%> | ||
# Post Script | ||
<%= input("post_script") %> | ||
RETVAL=$? | ||
[ $RETVAL -eq 0 ] || exit_with_message "Post script failed" $RETVAL | ||
<% end -%> |