Sha256: 20a70d10f9c8561d12f95ca89fa4d83dd1d8e5c5a6803a2ae18a76d2fcae2d76

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

<%#
kind: job_template
name: Package Action - SSH Default
job_name: Package Action
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

1 entries across 1 versions & 1 rubygems

Version Path
foreman_remote_execution-0.1.2 app/views/templates/package_action.erb