Puppet Plan: complyadm::preflight

Defined in:
plans/preflight.pp

Overview

A plan to check whether the configured infra is fit for Comply installation and prints results. Runs all “sub” preflight plans.

Parameters:

  • ignore_failing_preflights (Optional[Boolean]) (defaults to: false)

    Setting to true will ignore failed preflight checks.

  • config (Complyadm::Config) (defaults to: complyadm::config())

    Complyadm::Config config object from hiera



9
10
11
12
13
14
15
16
17
18
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
48
49
50
# File 'plans/preflight.pp', line 9

plan complyadm::preflight(
  Optional[Boolean] $ignore_failing_preflights = false,
  Complyadm::Config $config = complyadm::config()
) {
  without_default_logging () || {
    $arch_result = run_plan('complyadm::preflight::architecture', config => $config)
    out::message(complyadm::checks::format_results('architecture: checking for supported configuration', $arch_result))

    if(length($arch_result['failed']) > 0) {
      out::message(complyadm::checks::format_summary([$arch_result]))
      fail_plan($arch_result['failed'][0], 'comply/error')
    }

    $targets = $config['all_targets']

    $runtime_conflict_result = run_plan('complyadm::preflight::runtime::conflict', config => $config)
    out::message(complyadm::checks::format_results('runtime: checking for installed container runtimes', $runtime_conflict_result))

    apply_prep($targets, { '_run_as' => 'root' })

    $memory_result = run_plan('complyadm::preflight::memorycheck', config => $config)
    out::message(complyadm::checks::format_results('memory: checking for required 7 GiB', $memory_result))

    $os_result = run_plan('complyadm::preflight::oscheck', config => $config)
    out::message(complyadm::checks::format_results('os: checking for supported operating system', $os_result))

    $processor_result = run_plan('complyadm::preflight::processorcheck', config => $config)
    out::message(complyadm::checks::format_results('processors: checking for required 4 CPUs', $processor_result))

    $results = [$arch_result, $runtime_conflict_result, $memory_result, $os_result, $processor_result]
    out::message(complyadm::checks::format_summary($results))

    $aggregated_results = complyadm::checks::aggregate_results($results)

    if(length($aggregated_results[failed]) > 0) {
      if ( ! $ignore_failing_preflights) {
        fail_plan('One or more preflight checks did not pass', 'comply/error')
      }
      out::message('One or more preflight checks did not pass, continuing with installation anyway.')
    }
  }
}