Puppet Plan: complyadm::uninstall

Defined in:
plans/uninstall.pp

Summary

Uninstall Security Compliance Management and all associated data.

Overview

Use this plan to uninstall the Security Compliance Management application and all associated data. This removes Security Compliance Management from the hosts specified in the Hiera configuration file. The configured runtime must be functional, as it is used to remove the containers, volumes, and network associated with Security Compliance Management. The runtime itself is not removed, unless you explicitly choose to do so. For complete instructions on how to use this plan to uninstall Security Compliance Management, see www.puppet.com/docs/comply/3.x/comply_bolt_uninstall.

Parameters:

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

    Uninstall without prompting for confirmation



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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'plans/uninstall.pp', line 10

plan complyadm::uninstall(
  Optional[Boolean] $force = false,
) {
  run_plan('complyadm::check_bolt_version')

  $config = complyadm::config()

  $host = $config['roles']['backend']['targets'][0]

  if(!$force) {
    $warning_message = @("WARNING_MESSAGE")
      This plan will remove the Security Compliance Management application and all associated data from '${host}'.
      The ${config['runtime']} runtime must be functional for this plan to successfully remove all components.

      | WARNING_MESSAGE

    out::message($warning_message)
    $really_want_to_uninstall = Boolean(prompt("Do you want to continue with uninstalling Security Compliance Management on '${host}'?", 'default' => 'n'))

    if !$really_want_to_uninstall {
      fail_plan('Exiting uninstall')
    }

    $uninstall_runtime = Boolean(prompt("Would you like to uninstall ${config['runtime']}?", 'default' => 'n'))
  }

  $db_role = $config['roles']['database']['services']['comply_postgres']

  $database_info = Complyadm::Support_bundle::Database_info.new({
      'container_name' => $db_role['container']['name'],
      'database_user'  => $db_role['admin_db_username'],
  })

  $roles = $config['roles']
  $container_info = [
    $roles['ui']['services']['comply_ui']['container'],
    $roles['ui']['services']['comply_ui_assessor_init']['container'],

    $roles['backend']['services']['comply_graphql']['container'],
    $roles['backend']['services']['comply_scarpy']['container'],
    $roles['backend']['services']['comply_redis']['container'],
    $roles['backend']['services']['comply_identity']['container'],
    $roles['backend']['services']['comply_gatekeeper']['container'],
    $roles['backend']['services']['comply_frontdoor']['container'],
    $roles['backend']['services']['comply_mtls_proxy']['container'],
    $roles['backend']['services']['comply_graphql_init']['container'],
    $roles['backend']['services']['comply_scarpy_assessor_init']['container'],
    $roles['backend']['services']['comply_scarpy_init']['container'],
    $roles['backend']['services']['comply_assessor_upgrade']['container'],

    $roles['database']['services']['comply_postgres']['container'],
  ]

  $result = run_task(
    'complyadm::uninstall',
    # TODO: Currently only supports a single target
    $host,
    {
      'runtime'       => $config['runtime'],
      'backup_dir'    => $config['backup_dir'],
      'containers'    => $container_info,
      '_run_as'       => 'root',
      '_catch_errors' => true,
    }
  )

  # Log the output at debug level so we can at least use
  # bolt-debug.log to see what happened in the event of an issue
  log::debug($result[0].value['message'])

  if($result[0].ok) {
    out::message("Security Compliance Management has been removed from '${host}'.")
  } else {
    $error_message = @("ERROR")
      Uninstall failed on '${host}':

      ${$result[0]['_error']['msg']}

      Check the bolt-debug.log for additional details.
      | ERROR
    fail_plan($error_message)
  }

  # Uninstall the runtime if requested (or force=true)
  if ($force or $uninstall_runtime) {
    $runtime_result = run_plan('complyadm::uninstall::runtime',
      config => $config,
    )

    if($runtime_result[0].ok) {
      out::message("${config['runtime']} has been removed from '${host}'.")
    } else {
      $error_message = @("ERROR")
        Uninstall failed on '${host}':

        ${$runtime_result[0]['_error']['msg']}

        Check the bolt-debug.log for additional details.
        | ERROR
      fail_plan($error_message)
    }
  }

  out::message('Uninstall complete.')
}