Puppet Plan: cd4peadm::preflight::memorycheck

Defined in:
plans/preflight/memorycheck.pp

Overview

A plan to check whether the target machine(s) meet(s) our total memory requirements

Parameters:

  • config (Cd4peadm::Config) (defaults to: cd4peadm::config())

    Cd4peadm::Config config object from Hiera

Returns:

  • Hash A hash with pass and/or fail messages



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'plans/preflight/memorycheck.pp', line 8

plan cd4peadm::preflight::memorycheck(
  Cd4peadm::Config $config = cd4peadm::config()
) {
  $targets = $config['all_targets']

  $required_memory_bytes = 8000000000
  $required_memory_gib = '7.45 GiB'

  $results = $targets.reduce({ passed => [], failed => [] }) |$memo, $target| {
    $facts_from_target = get_target($target).facts()
    $found_memory_bytes = $facts_from_target['memory']['system']['total_bytes']
    $found_memory_gib = $facts_from_target['memory']['system']['total']

    if($found_memory_bytes <= $required_memory_bytes) {
      $failed = $memo['failed'] << "${target} : found ${found_memory_gib}"
      $memo + { 'failed' => $failed }
    } else {
      $passed = $memo['passed'] << "${target} : found ${found_memory_gib}"
      $memo + { 'passed' => $passed }
    }
  }

  return $results
}