Puppet Plan: mq_install::apply_fixpack

Defined in:
plans/apply_fixpack.pp

Summary

Apply the in hiera specified MQ fixpack to the specified nodes.

Overview

This bolt plan applies the pending MQ software updates specified in the hieradata, to the nodes that are targeted.

## How does it work

It applies the puppet class ‘mq_install::fixpack` to the named targets.Because the service window is set to DIRECT, applying the upgrade will start immediately.

If the any MQ managers are running, they will be stopped before applying the MQ fixpack. After the fickpack is done The plan will restart any queue managers that were started before the start of the plan.

## Take care

This puppet plan expects a prerequisite that all of the values for the ‘mq_install::fixpack` class are resolvable through hiera. If this is not the case, the puppet plan will fail, citing that it cannot find one of the parameters.

The best way is to use the same hiera config for this puppet task as the hiera config you use for regular puppet runs. Take care, however that hiera in bolt/puppet plans cannot access trusted facts in the hiera config.

See the file “LICENSE” for the full license governing this code.

Examples:


bolt --hiera_config /etc/puppetlabs/code/environments/production/hiera.yaml --modulepath /etc/puppetlabs/code/environments/production/modules/ plan run mq_install::apply_fixpack --targets server1,server2

Parameters:

  • targets (TargetSpec)

    The MQ node(s) you want to apply a software update to



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'plans/apply_fixpack.pp', line 31

plan mq_install::apply_fixpack(
  TargetSpec $targets,
) {
  #
  # Prepare the target(s) for use of EM licensed modules
  #
  easy_type::em_prep($targets)
  # 
  # Under the hood the mq_install:fixpack class uses these facts, types
  # and providers. We also sync the em_license module to have
  # be able to access the available licenses
  # 
  $used_modules = ['easy_type', 'mq_install', 'mq_config','em_license', 'echo', 'archive', 'systemd', 'stdlib']
  apply_prep($targets, { '_required_modules' => $used_modules })

  #
  # Apply the fixp[ack class to the target(s). This class will
  # do all the hard lifting for us.
  #
  $results = apply($targets, { '_required_modules' => $used_modules, '_catch_errors' => true }) {
    class { 'mq_install::fixpack':
      service_window => 'DIRECT',
    }
    #
    # Now start all queue managers that where started before the fixpack
    #
    $facts['mq_managers'].each | $manager| {
      $name  = dig($manager, 'name')
      $state = dig($manager, 'state')
      if $state == 'Running' {
        mq_install::autostart { $name:
          require => Class['mq_install::fixpack'],
        }
      }
    }
  }
  $results.each |$target_result| {
    if $target_result.error {
      fail_plan($target_result.error())
      $target_result.report['logs'].each |$log| {
        out::message("${log['source']}: ${log['message']}")
      }
    } else {
      $target_result.report['logs'].each |$log| {
        out::message("${log['source']}: ${log['message']}")
      }
    }
  }
}