Puppet Plan: complyadm::support_bundle

Defined in:
plans/support_bundle.pp

Summary

Gather information to help diagnose issues when contacting support.

Overview

Use this plan to gather information detailing the state of an existing Security Compliance Management installation and save it to the support bundle directory. When you run the plan, the location of the support bundle is returned. You can send this bundle to Puppet support to help them diagnose an issue.

Parameters:

  • identifier (Optional[String[1]]) (defaults to: undef)

    An identifier, such as a support ticket number

  • compress (Optional[Boolean]) (defaults to: true)

    Specifies whether or not the resulting directory should be compressed using tar/gzip



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
# File 'plans/support_bundle.pp', line 12

plan complyadm::support_bundle(
  Optional[String[1]] $identifier = undef,
  Optional[Boolean] $compress = true,
) {
  run_plan('complyadm::check_bolt_version')

  $config = complyadm::config()
  out::message('Generating support bundle. This may take several minutes...')
  if($identifier != undef) {
    if($identifier !~ /^[a-zA-Z0-9\-\_]*$/) {
      fail_plan("The supplied identifier '${identifier}' must contain only letters, numbers, dashes, or underscores")
    }
    $id = "${identifier}-"
  } else {
    $id = ''
  }
  $support_bundle_dir_name = "supportbundle-${id}${Timestamp.new.strftime('%Y-%m-%dT%H_%M_%S')}"
  $downloads_path = complyadm::download_dir()
  if (!file::exists($downloads_path)) {
    without_default_logging() || {
      run_command("mkdir -p ${downloads_path}", 'localhost')
    }
  }
  $support_bundle_path = file::join($downloads_path, $support_bundle_dir_name)
  if (file::exists($support_bundle_path)) {
    fail_plan("Failed to generate support bundle because path already exists at:\n '${support_bundle_path}'\n Try re-running the plan.")
  }
  without_default_logging() || {
    run_command("mkdir ${support_bundle_path}", 'localhost')
  }

  out::message('Collecting target info...')
  run_plan('complyadm::support_bundle::collect_target_info', 'config' => $config, 'root_dir' => $support_bundle_path)

  out::message('Collecting configuration information from the Comply module..')
  run_plan(
    'complyadm::support_bundle::config',
    'support_bundle_dir' => $support_bundle_path,
    'config' => $config,
  )

  # These commands must come last because as this plan runs it will also log to bolt-debug.log so
  # we need to copy it after running the other commands so we don't miss anything.
  out::message('Adding Bolt debug log to support bundle..')
  without_default_logging() || {
    run_command("cp ${complyadm::bolt_project_dir()}/bolt-debug.log ${support_bundle_path}", 'localhost')
  }

  if($compress) {
    $tar_path = file::join($downloads_path, "${support_bundle_dir_name}.tar.gz")
    without_default_logging() || {
      run_command("tar czf ${tar_path} --directory=${downloads_path} ${support_bundle_dir_name}", 'localhost')
    }
    out::message("Generated support bundle at ${$tar_path}")
    $output_path = $tar_path
    # The -r flag of the rm command requires that all files be writable. 
    # Our plan may create files that aren't if the user's umask doesn't allow for it.
    without_default_logging() || {
      run_command("rm -r ${support_bundle_path}", 'localhost')
    }
  } else {
    $output_path = $support_bundle_path
    out::message("Generated support bundle directory at ${$support_bundle_path}")
  }

  $output = { 'support_bundle_path' => $output_path }
  return $output
}