Puppet Plan: complyadm::ctl

Defined in:
plans/ctl.pp

Summary

Start, stop, restart, or check the status of a service.

Overview

Use this plan to run systemctl subcommands for the specified service.

Parameters:

  • service (Optional[Enum['comply_graphql', 'comply_scarpy', 'comply_redis', 'comply_identity', 'comply_gatekeeper', 'comply_frontdoor', 'comply_mtls_proxy', 'comply_graphql_init', 'comply_scarpy_assessor_init', 'comply_scarpy_init', 'comply_assessor_upgrade', 'comply_postgres', 'comply_ui', 'all']]) (defaults to: 'all')

    The name of the target service

  • action (Optional[Enum['status', 'start', 'stop', 'restart']]) (defaults to: 'status')

    What action to perform on the service



7
8
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/ctl.pp', line 7

plan complyadm::ctl(
  Optional[Enum['status', 'start', 'stop', 'restart']] $action = 'status',
  Optional[Enum['comply_graphql', 'comply_scarpy', 'comply_redis', 'comply_identity', 'comply_gatekeeper', 'comply_frontdoor', 'comply_mtls_proxy', 'comply_graphql_init', 'comply_scarpy_assessor_init', 'comply_scarpy_init', 'comply_assessor_upgrade', 'comply_postgres', 'comply_ui', 'all']] $service = 'all',
) {
  $config = complyadm::config()
  $opts = { '_run_as' => 'root', '_catch_errors' => true, }

  $roles = $config['roles']
  $role_map = {
    'comply_graphql'              => 'backend',
    'comply_scarpy'               => 'backend',
    'comply_redis'                => 'backend',
    'comply_identity'             => 'backend',
    'comply_gatekeeper'           => 'backend',
    'comply_frontdoor'            => 'backend',
    'comply_mtls_proxy'           => 'backend',
    'comply_graphql_init'         => 'backend',
    'comply_scarpy_assessor_init' => 'backend',
    'comply_scarpy_init'          => 'backend',
    'comply_assessor_upgrade'     => 'backend',
    'comply_postgres'             => 'database',
    'comply_ui'                   => 'ui',
    'comply_ui_assessor_init'     => 'ui',
  }

  $services = $service ? {
    'all'   => ['comply_graphql', 'comply_scarpy', 'comply_redis', 'comply_identity', 'comply_gatekeeper', 'comply_frontdoor', 'comply_mtls_proxy', 'comply_graphql_init', 'comply_scarpy_assessor_init', 'comply_scarpy_init', 'comply_assessor_upgrade', 'comply_postgres', 'comply_ui'],
    default => [$service],
  }

  $services.each |$svc| {
    $results = run_command("systemctl ${action} ${config['runtime']}-${svc}", $roles[$role_map[$svc]]['targets'], $opts)
    $results.each |$result| {
      if(!$result['stdout'].empty) {
        out::message("Result from ${result.target}")
        out::message($result['stdout'])
      }
    }
  }

  if($service == 'all' and $action in ['start', 'restart']) {
    run_plan('complyadm::install::wait_for_services', config => $config)
  }
}