Sha256: 3be298619d63e0cc0fa29170e9a8ac92a9c5ee880142063dc28a2327d181734c

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

<%#
kind: job_template
name: Package Action - SSH Default
job_category: Packages
description_format: "%{action} package(s) %{package}"
provider_type: SSH
template_inputs:
- name: pre_script
  description: A script to run prior to the package action
  input_type: user
  required: false
- name: action
  description: 'The package action: install, update, or remove'
  input_type: user
  required: true
  options: "install\nupdate\nremove"
- name: package
  description: The name of the package, if any
  input_type: user
  required: false
- name: post_script
  description: A script to run after the package action
  input_type: user
  required: false
%>

die() {
  echo "${1}, exiting..."
  exit $2
}

<% unless input("pre_script").blank? -%>
  # Pre Script
  <%= input("pre_script") %>
  RETVAL=$?
  [ $RETVAL -eq 0 ] || die "Pre script failed" $RETVAL
<% end -%>

# Action
<% if @host.operatingsystem.family == 'Redhat' -%>
  yum -y <%= input("action") %> <%= input("package") %>
<% elsif @host.operatingsystem.family == 'Debian' -%>
  apt-get -y <%= input("action") %> <%= input("package") %>
<% end -%>
RETVAL=$?
[ $RETVAL -eq 0 ] || die "Package action failed" $RETVAL

<% unless input("post_script").blank? -%>
  # Post Script
  <%= input("post_script") %>
  RETVAL=$?
  [ $RETVAL -eq 0 ] || die "Post script failed" $RETVAL
<% end -%>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_remote_execution-0.2.3 app/views/templates/package_action.erb
foreman_remote_execution-0.2.2 app/views/templates/package_action.erb
foreman_remote_execution-0.2.1 app/views/templates/package_action.erb