Puppet Plan: complyadm::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 (Complyadm::Config) (defaults to: complyadm::config())

    Complyadm::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
# File 'plans/preflight/memorycheck.pp', line 8

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

  $required_memory_bytes = 7000000000

  $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
}