Puppet Class: psick::ci::octocatalog

Defined in:
manifests/ci/octocatalog.pp

Overview

This class installs and configures via tp the octocatalog-diff tool, used to compare Puppet catalogs from different sources

Parameters:

  • ensure (String) (defaults to: 'present')

    Define if to install (present), remote (absent) or the version of the octocatalog-diff gem

  • auto_prereq (Boolean) (defaults to: false)

    Define if to automatically install the prerequisites needed by octocatalog-diff

  • template (Optional[String]) (defaults to: undef)

    The path of the erb template (as used in template()) to use as content for the octocatalog-diff configuration file

  • options (Hash) (defaults to: { })

    An open hash of options you can use in your template. Note that this hash is merged with an hash of default options provided in the class

  • git_repo (Optional[String]) (defaults to: undef)

    The url of a git repo to clone locally, in the git_repo_dir. You ay not need it in CI pipelines where git operations are automatically done

  • git_repo_dir (String) (defaults to: '/srv/control-repo')

    The path of the directory where to clone the git_repo

  • run_as_user (String) (defaults to: 'root')

    The user octocatalog-diff is supposed to be executed as

  • manage (Boolean) (defaults to: $::psick::manage)
  • noop_manage (Boolean) (defaults to: $::psick::noop_manage)
  • noop_value (Boolean) (defaults to: $::psick::noop_value)


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
# File 'manifests/ci/octocatalog.pp', line 19

class psick::ci::octocatalog (
  String           $ensure       = 'present',
  Boolean          $auto_prereq  = false,
  Optional[String] $template     = undef,
  Hash             $options      = { },
  Optional[String] $git_repo     = undef,
  String           $git_repo_dir = '/srv/control-repo',
  String           $run_as_user  = 'root', # In CI setups set this to the CI user

  Boolean          $manage       = $::psick::manage,
  Boolean          $noop_manage  = $::psick::noop_manage,
  Boolean          $noop_value   = $::psick::noop_value,
) {

  if $manage {
    if $noop_manage {
      noop($noop_value)
    }

    if $run_as_user =='root' {
      $private_key_path = "/etc/puppetlabs/puppet/ssl/private_keys/${trusted['certname']}.pem"
    } else {
      $private_key_path = "/home/${run_as_user}/${trusted['certname']}.pem"
      file { $private_key_path:
        ensure => file,
        owner  => $run_as_user,
        group  => $run_as_user,
        mode   => '0400',
        source => "file:///etc/puppetlabs/puppet/ssl/private_keys/${trusted['certname']}.pem",
      }
    }
    $options_default = {
      'hiera_config' => 'hiera.yaml',
      'hiera_path' => 'hieradata',
      'puppetdb_url' => 'https://localhost:8081',
      'puppetdb_ssl_ca' => '/etc/puppetlabs/puppet/ssl/certs/ca.pem',
      'puppetdb_ssl_client_key_path' => $private_key_path,
      'puppetdb_ssl_client_cert_path' => "/etc/puppetlabs/puppet/ssl/certs/${trusted['certname']}.pem",
      'storeconfigs' => false,
      'bootstrap_script' => 'bin/puppet_install_puppetfile.sh',
      'puppet_binary' => '/opt/puppetlabs/puppet/bin/puppet',
      'from_env' => 'origin/production',
      'header' => ':default',
      'cached_master_dir' => "File.join(ENV['HOME'], '.octocatalog-diff-cache')",
      'safe_to_delete_cached_master_dir' => 'settings[:cached_master_dir]',
      'basedir' => 'Dir.pwd',
    }
    $octocatalog_options = $options_default + $options
    ::tp::install { 'octocatalog-diff' :
      ensure      => $ensure,
      auto_prereq => $auto_prereq,
    }

    if $template {
      ::tp::conf { 'octocatalog-diff':
        ensure       => $ensure,
        template     => $template,
        options_hash => $octocatalog_options,
      }
    }

    if $git_repo {
      ::tp::dir { 'octocatalog-diff::git_repo':
        ensure  => $ensure,
        source  => $git_repo,
        path    => $git_repo_dir,
        vcsrepo => 'git',
      }
    }
  }
}