Puppet Class: puppet::r10k::config

Inherits:
puppet::params
Defined in:
manifests/r10k/config.pp

Summary

Default r10k configuration file

Overview

The r10k configuration file is created only if r10k.yaml does not already exist. By default, it establishes the ‘production` environment. Optionally, it can also configure `common` and `enc` environments.

Examples:

include puppet::r10k::config

Parameters:

  • r10k_config_setup (Boolean) (defaults to: $puppet::r10k_config_setup)

    Determines the management strategy for the r10k configuration file: whether to update it on each notify event or to only create it if it does not already exist.

  • r10k_yaml_template (String) (defaults to: $puppet::r10k_yaml_template)

    Allows the specification of a custom r10k.yaml ERB (Embedded Ruby) template for setup, instead of using the default template provided.

  • cachedir (Stdlib::Absolutepath) (defaults to: $puppet::params::r10k_cachedir)

    This parameter allows for the customization of the r10k cache directory path, aligning with the ‘cachedir` parameter specified inside the r10k configuration.

  • environmentpath (Stdlib::Absolutepath) (defaults to: $puppet::params::environmentpath)

    Specifies the directory path to Puppet environments. This parameter corresponds to the ‘basedir` parameter for each source defined in the r10k configuration.

  • production_remote (String) (defaults to: $puppet::production_remote)

    Sets the Git repository URL for the ‘production` environment. This setting aligns with the `remote` parameter designated for the `production` source in the r10k configuration. The default URL is github.com/aursu/control-init.git.

  • use_common_env (Boolean) (defaults to: $puppet::use_common_env)

    Determines whether to setup the ‘common` environment.

  • common_remote (String) (defaults to: $puppet::common_remote)

    Sets the Git repository URL for the ‘common` environment. This setting aligns with the `remote` parameter designated for the `common` source in the r10k configuration. The default URL is github.com/aursu/control-common.git.

  • use_enc (Boolean) (defaults to: $puppet::use_enc)

    Determines whether to setup the ‘enc` environment.

  • enc_remote (String) (defaults to: $puppet::enc_remote)

    Sets the Git repository URL for the ‘enc` environment. This setting aligns with the `remote` parameter designated for the `enc` source in the r10k configuration. The default URL is github.com/aursu/control-enc.git.



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
# File 'manifests/r10k/config.pp', line 49

class puppet::r10k::config (
  String  $r10k_yaml_template = $puppet::r10k_yaml_template,
  Stdlib::Absolutepath $cachedir = $puppet::params::r10k_cachedir,
  Stdlib::Absolutepath $environmentpath = $puppet::params::environmentpath,
  Boolean $r10k_config_setup = $puppet::r10k_config_setup,
  String  $production_remote = $puppet::production_remote,
  Boolean $use_common_env = $puppet::use_common_env,
  String  $common_remote = $puppet::common_remote,
  Boolean $use_enc = $puppet::use_enc,
  String  $enc_remote = $puppet::enc_remote,
) inherits puppet::params {
  include puppet::r10k::setup

  # /opt/puppetlabs/puppet/cache/r10k
  $r10k_vardir = "${facts['puppet_vardir']}/r10k"
  $r10k_config_file = $puppet::params::r10k_config_file

  # this should be one time installation
  file { "${r10k_vardir}/r10k.yaml":
    content => template($r10k_yaml_template),
    mode    => '0600',
    owner   => 'root',
    group   => 'root',
    notify  => Exec['r10k-config'],
  }

  if $r10k_config_setup {
    # only if ${r10k_vardir}/r10k.yaml just created or changed
    exec { 'r10k-config':
      command     => "cp ${r10k_vardir}/r10k.yaml ${r10k_config_file}",
      refreshonly => true,
      path        => '/bin:/usr/bin',
    }
  }
  else {
    # only if config file not exists
    exec { 'r10k-config':
      command => "cp ${r10k_vardir}/r10k.yaml ${r10k_config_file}",
      creates => $r10k_config_file,
      path    => '/bin:/usr/bin',
    }
  }

  Class['puppet::r10k::setup'] -> File["${r10k_vardir}/r10k.yaml"]
  Class['puppet::r10k::setup'] -> Exec['r10k-config']
}