Puppet Plan: peadm::util::sanitize_pg_pe_conf

Defined in:
plans/util/sanitize_pg_pe_conf.pp

Overview

Parameters:

  • targets (TargetSpec)
  • primary_host (Peadm::SingleTargetSpec)


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

plan peadm::util::sanitize_pg_pe_conf (
  TargetSpec              $targets,
  Peadm::SingleTargetSpec $primary_host,
) {
  $primary_target = get_target($primary_host)

  $path = '/etc/puppetlabs/enterprise/conf.d/pe.conf'
  # Ensure the pe.conf file on PostgreSQL nodes has the needed values for
  # puppet_primary_host and database_host
  run_task('peadm::read_file', $targets,
    path => $path,
  ).map |$result| {
    out::message("Sanitizing pe.conf on ${result.value}")
    $sanitized = $result.value['content'].parsejson() + {
      'puppet_enterprise::puppet_master_host' => $primary_target.peadm::certname(),
      'puppet_enterprise::puppetdb_database_host'      => $result.target.peadm::certname(),
    }

    out::message("Sanitized ${sanitized}")

    # Return the result of file_content_upload. There is only one target
    peadm::file_content_upload(stdlib::to_json_pretty($sanitized), $path, $result.target)[0]
  }
}