Puppet Plan: peadm::backup_ca

Defined in:
plans/backup_ca.pp

Overview

Parameters:

  • target (Peadm::SingleTargetSpec)
  • output_directory (Optional[String]) (defaults to: '/tmp')


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'plans/backup_ca.pp', line 1

plan peadm::backup_ca(
  Peadm::SingleTargetSpec $target,
  Optional[String]                  $output_directory = '/tmp',
) {
  out::message('# Backing up ca and ssl certificates')
  # lint:ignore:strict_indent

  $timestamp = Timestamp.new().strftime('%Y-%m-%dT%H%M%SZ')
  $backup_directory = "${output_directory}/pe-backup-${timestamp}"

  # Create backup folder
  apply($target) {
    file { $backup_directory :
      ensure => 'directory',
      owner  => 'root',
      group  => 'root',
      mode   => '0700',
    }
  }

  run_command(@("CMD"), $target)
    /opt/puppetlabs/bin/puppet-backup create --dir=${shellquote($backup_directory)} --name=ca_backup.tgz --scope=certs
    | CMD
  # lint:endignore
  return({ 'path' => "${backup_directory}/ca_backup.tgz" })
}