Puppet Class: psick::puppet::pe_client_tools

Defined in:
manifests/puppet/pe_client_tools.pp

Overview

This class installs and configures PE client tools

Parameters:

  • ensure (Enum['present','absent']) (defaults to: present)
  • download_base_url (String) (defaults to: 'https://pm.puppetlabs.com/pe-client-tools')
  • package_url (Optional[String]) (defaults to: undef)
  • package_name (Optional[String]) (defaults to: undef)
  • pe_version (String) (defaults to: '2021.5.0')
  • repo_path (String) (defaults to: '')
  • package_suffix (String) (defaults to: '')
  • package_separator (String) (defaults to: '-')
  • package_download_dir (String) (defaults to: '/var/tmp')
  • token (Optional[String]) (defaults to: undef)
  • token_user (String) (defaults to: 'root')
  • puppet_server (String) (defaults to: $servername)
  • puppetdb_server (String) (defaults to: $servername)
  • console_server (String) (defaults to: $servername)
  • orchestrator_options (Hash) (defaults to: {})
  • puppet_access_options (Hash) (defaults to: {})
  • puppet_code_options (Hash) (defaults to: {})
  • puppetdb_options (Hash) (defaults to: {})
  • manage (Boolean) (defaults to: $psick::manage)
  • noop_manage (Boolean) (defaults to: $psick::noop_manage)
  • noop_value (Boolean) (defaults to: $psick::noop_value)


3
4
5
6
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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'manifests/puppet/pe_client_tools.pp', line 3

class psick::puppet::pe_client_tools (
  Enum['present','absent'] $ensure = present,

  String $download_base_url        = 'https://pm.puppetlabs.com/pe-client-tools',
  Optional[String] $package_url    = undef,
  Optional[String] $package_name   = undef,

  String $pe_version               = '2021.5.0',
  String $repo_path                = '', # lint:ignore:params_empty_string_assignment
  String $package_suffix           = '', # lint:ignore:params_empty_string_assignment
  String $package_separator        = '-',
  String $package_download_dir     = '/var/tmp',

  Optional[String] $token          = undef,
  String $token_user               = 'root',
  String $puppet_server            = $servername,
  String $puppetdb_server          = $servername,
  String $console_server           = $servername,

  Hash $orchestrator_options       = {},
  Hash $puppet_access_options      = {},
  Hash $puppet_code_options        = {},
  Hash $puppetdb_options           = {},
  Boolean $manage                  = $psick::manage,
  Boolean $noop_manage             = $psick::noop_manage,
  Boolean $noop_value              = $psick::noop_value,
) {
  if $manage {
    if $noop_manage {
      noop($noop_value)
    }

    $pe_short_version = regsubst($pe_version,'^20','')

    # Madness will be
    $pe_patch = $pe_short_version ? {
      '21.5.0' => $facts['kernel'] ? {
        'windows' => '',
        default   => '-1',
      },
      default  => '',
    }

    $full_package_url = $package_url ? {
      undef   => "${download_base_url}/${pe_version}/${pe_short_version}/repos/${repo_path}/pe-client-tools${package_separator}${pe_short_version}${pe_patch}${package_suffix}", # lint:ignore:140chars
      default => $package_url,
    }
    $full_package_name = $package_name ? {
      undef   => "pe-client-tools${package_separator}${pe_short_version}${pe_patch}${package_suffix}", # lint:ignore:140chars
      default => $package_name,
    }

    $package_provider = $facts['os']['family'] ? {
      'RedHat'  => 'rpm',
      'Debian'  => 'dpkg',
      'Suse'    => 'rpm',
      'Darwin'  => 'pkgdmg',
      'windows' => 'windows',
      default   => undef,
    }

    psick::netinstall { 'pe-client-tools':
      url             => $full_package_url,
      destination_dir => $package_download_dir,
      work_dir        => $package_download_dir,
      extract_command => false,
    }
    -> package { 'pe-client-tools':
      ensure   => $ensure,
      provider => $package_provider,
      source   => "${package_download_dir}/${full_package_name}",
    }

    if $token {
      $puppetlabs_dir = $token_user ? {
        'root'  => '/root/.puppetlabs/',
        default => $facts[os][family] ? {
          'Darwin'  => "/Users/${token_user}/.puppetlabs/",
          'windows' => "C:/Users/${token_user}/.puppetlabs/",
          default   => "/home/${token_user}/.puppetlabs/",
        }
      }
      psick::tools::create_dir { "pe-client-tools token dir ${puppetlabs_dir}":
        path   => $puppetlabs_dir,
        owner  => $token_user,
        before => File["${puppetlabs_dir}/token"],
      }
      file { "${puppetlabs_dir}/token":
        ensure  => $ensure,
        content => $token,
        owner   => $token_user,
      }
    }

    $orchestrator_defaults = {
      'options' => {
        'service-url' => "https://${puppet_server}:8143",
      },
    }
    file { '/etc/puppetlabs/client-tools/orchestrator.conf':
      ensure  => $ensure,
      content => to_json($orchestrator_defaults + $orchestrator_options),
      require => Package['pe-client-tools'],
    }

    $puppet_access_defaults = {
      'service-url' => "https://${console_server}:8433/rbac-api",
    }
    file { '/etc/puppetlabs/client-tools/puppet-access.conf':
      ensure  => $ensure,
      content => to_json($puppet_access_defaults + $puppet_access_options),
      require => Package['pe-client-tools'],
    }

    $puppet_code_defaults = {
      'service-url' => "https://${puppet_server}:8170/code-manager",
    }
    file { '/etc/puppetlabs/client-tools/puppet-code.conf':
      ensure  => $ensure,
      content => to_json($puppet_code_defaults + $puppet_code_options),
      require => Package['pe-client-tools'],
    }

    $puppetdb_defaults = {
      'puppetdb' => {
        'server-urls' => "https://${puppetdb_server}:8081",
        'cacert'      => '/etc/puppetlabs/puppet/ssl/certs/ca.pem',
      },
    }
    file { '/etc/puppetlabs/client-tools/puppetdb.conf':
      ensure  => $ensure,
      content => to_json($puppetdb_defaults + $puppetdb_options),
      require => Package['pe-client-tools'],
    }
  }
}