Defined Type: yum::post_transaction_action

Defined in:
manifests/post_transaction_action.pp

Summary

Creates post transaction configuratons for dnf or yum.

Overview

Examples:

Touch a file when ssh is package is updated, installed or removed.

yum::post_transaction_action{'touch file on ssh package update':
  key     => 'openssh-*',
  state   => 'any',
  command => 'touch /tmp/openssh-installed',
}

Parameters:

  • action (String[1]) (defaults to: $title)

    Name variable a string to label the rule

  • key (Variant[Enum['*'],Yum::RpmNameGlob,Stdlib::Unixpath])

    Package name, glob or file name file glob.

  • state (Enum['install', 'update', 'remove', 'any', 'in', 'out']) (defaults to: 'any')

    Can be ‘install`, `update`, `remove` or `any` on YUM based systems. Can be `in`, `out` or `any` on DNF based systems.

  • command (String[1])

    The command to run

See Also:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'manifests/post_transaction_action.pp', line 19

define yum::post_transaction_action (
  Variant[Enum['*'],Yum::RpmNameGlob,Stdlib::Unixpath] $key,
  String[1] $command,
  Enum['install', 'update', 'remove', 'any', 'in', 'out'] $state = 'any',
  String[1] $action = $title,
) {
  #
  # The valid Enum is different for yum and dnf based systems.
  #
  if $facts['package_provider'] == 'yum' {
    assert_type(Enum['install','update','remove','any'],$state) |$expected, $actual| {
      fail("The state parameter on ${facts['package_provider']} based systems should be \'${expected}\' and not \'${actual}\'")
    }
  } else {
    assert_type(Enum['in', 'out', 'any'],$state) |$expected, $actual| {
      fail("The state parameter on ${facts['package_provider']} based systems should be \'${expected}\' and not \'${actual}\'")
    }
  }

  require yum::plugin::post_transaction_actions

  if $yum::plugin::post_transaction_actions::ensure == 'present' {
    concat::fragment { "post_trans_${action}":
      target  => 'puppet_actions',
      content => "# Action name: ${action}\n${key}:${state}:${command}\n\n",
      order   => '10',
    }
  }
}