Defined Type: patching::script

Defined in:
manifests/script.pp

Summary

manages a script for custom patching actions

Overview

Examples:

Basic usage from static file

include patching
patching::script { 'pre_patch.sh':
  source => 'puppet://mymodule/patching/custom_app_pre_patch.sh',
}

Basic usage from template

include patching
patching::script { 'pre_patch.sh':
  content => template('mymodule/patching/custom_app_pre_patch.sh'),
}

Installing the script into a different path with a different name

include patching
patching::script { 'custom_app_pre_patch.sh':
  content => template('mymodule/patching/custom_app_pre_patch.sh'),
  bin_dir => '/my/custom/app/patching/dir',
}

Installing multiple scripts into a different path

class {'patching':
  bin_dir => '/my/custom/app/patching/dir',
}

# we don't have to override bin_dir on each of these because
# we configured it gobally in the patching class above
patching::script { 'custom_app_pre_patch.sh':
  content => template('mymodule/patching/custom_app_pre_patch.sh'),
}
patching::script { 'custom_app_post_patch.sh':
  content => template('mymodule/patching/custom_app_post_patch.sh'),
}

From hiera

patching::bin_dir: '/my/custom/app/patching/dir'
patching::scripts:
  custom_app_pre_patch.sh:
    source: 'puppet:///mymodule/patching/custom_app_pre_patch.sh'
  custom_app_post_patch.sh:
    source: 'puppet:///mymodule/patching/custom_app_post_patch.sh'

Parameters:

  • source (Any) (defaults to: undef)

    Source (puppet path) for the ‘file` resource of the script. Either `source` our `content` must be specified. If neither are specified an error will be thrown.

  • content (Any) (defaults to: undef)

    Content (raw string, result of ‘template()`, etc) for the `file` resource of the script. Either `source` our `content` must be specified. If neither are specified an error will be thrown.

  • bin_dir (Any) (defaults to: $patching::bin_dir)

    Directory where the script will be installed

  • owner (Any) (defaults to: $patching::owner)

    Owner of the script file

  • group (Any) (defaults to: $patching::group)

    Group of the script file

  • mode (Any) (defaults to: $patching::mode)

    File mode to set on the script



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'manifests/script.pp', line 64

define patching::script (
  $source       = undef,
  $content      = undef,
  $bin_dir      = $patching::bin_dir,
  $owner        = $patching::owner,
  $group        = $patching::group,
  $mode         = $patching::mode,
) {
  if $source {
    file { "${bin_dir}/${name}":
      ensure => file,
      source => $source,
      owner  => $owner,
      group  => $group,
      mode   => $mode,
    }
  }
  elsif $content {
    file { "${bin_dir}/${name}":
      ensure  => file,
      content => $content,
      owner   => $owner,
      group   => $group,
      mode    => $mode,
    }
  }
  else {
    fail("Must specify either 'source' or 'content', we received 'undef' for both.")
  }
}