From aa6ab4db911f7c99ca2e2e7187cb6cd4e4ede092 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 28 Jul 2023 20:17:58 +0200 Subject: [PATCH] r10k::config: make class private --- REFERENCE.md | 355 +++++++++----------------------------------- manifests/config.pp | 120 ++++----------- manifests/init.pp | 42 +++--- 3 files changed, 119 insertions(+), 398 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index c50d41a9..e5586f62 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -6,8 +6,9 @@ ### Classes +#### Public Classes + * [`r10k`](#r10k): This class configures r10k -* [`r10k::config`](#r10k--config): == Class: r10k::config Set up the root r10k config file (/etc/r10k.yaml). === Parameters * [*cachedir*] Path to a directory to be used b * [`r10k::install`](#r10k--install): This class is used by the ruby or pe_ruby class * [`r10k::install::bundle`](#r10k--install--bundle): This class installs the r10k bundle * [`r10k::install::gem`](#r10k--install--gem): Install the r10k gem using system ruby @@ -22,6 +23,10 @@ * [`r10k::webhook::package`](#r10k--webhook--package): Class: r10k::webhook::package * [`r10k::webhook::service`](#r10k--webhook--service): Class: r10k::webhook::service +#### Private Classes + +* `r10k::config`: Set up the root r10k config file (/etc/r10k.yaml). + ### Data types * [`R10k::Webhook::Config`](#R10k--Webhook--Config) @@ -44,9 +49,15 @@ This class configures r10k The following parameters are available in the `r10k` class: -* [`remote`](#-r10k--remote) -* [`sources`](#-r10k--sources) * [`cachedir`](#-r10k--cachedir) +* [`sources`](#-r10k--sources) +* [`postrun`](#-r10k--postrun) +* [`manage_configfile_symlink`](#-r10k--manage_configfile_symlink) +* [`configfile_symlink`](#-r10k--configfile_symlink) +* [`forge_settings`](#-r10k--forge_settings) +* [`proxy`](#-r10k--proxy) +* [`pool_size`](#-r10k--pool_size) +* [`remote`](#-r10k--remote) * [`configfile`](#-r10k--configfile) * [`version`](#-r10k--version) * [`puppet_master`](#-r10k--puppet_master) @@ -59,43 +70,86 @@ The following parameters are available in the `r10k` class: * [`gentoo_keywords`](#-r10k--gentoo_keywords) * [`install_options`](#-r10k--install_options) * [`mcollective`](#-r10k--mcollective) -* [`manage_configfile_symlink`](#-r10k--manage_configfile_symlink) -* [`configfile_symlink`](#-r10k--configfile_symlink) * [`git_settings`](#-r10k--git_settings) -* [`forge_settings`](#-r10k--forge_settings) * [`deploy_settings`](#-r10k--deploy_settings) * [`root_user`](#-r10k--root_user) -* [`proxy`](#-r10k--proxy) -* [`pool_size`](#-r10k--pool_size) * [`gem_source`](#-r10k--gem_source) * [`root_group`](#-r10k--root_group) -* [`postrun`](#-r10k--postrun) * [`include_prerun_command`](#-r10k--include_prerun_command) * [`include_postrun_command`](#-r10k--include_postrun_command) +* [`puppetconf_path`](#-r10k--puppetconf_path) -##### `remote` +##### `cachedir` Data type: `Any` +Path to a directory to be used by r10k for caching data - -Default value: `$r10k::params::remote` +Default value: `$r10k::params::r10k_cache_dir` ##### `sources` -Data type: `Any` - +Data type: `Optional[Hash]` +Hash containing data sources to be used by r10k to create dynamic Puppet environments Default value: `$r10k::params::sources` -##### `cachedir` +##### `postrun` + +Data type: `Optional[Array[String[1]]]` + +Array containing the parts of a system call Example: ['/usr/bin/curl', '-F', 'deploy=done', 'http://my-app.site/endpoint'] + +Default value: `undef` + +##### `manage_configfile_symlink` + +Data type: `Boolean` + +determine if a symlink to the r10k config file is to be managed + +Default value: `$r10k::params::manage_configfile_symlink` + +##### `configfile_symlink` + +Data type: `Stdlib::Absolutepath` + +Location of symlink that points to configfile + +Default value: `$r10k::params::configfile_symlink` + +##### `forge_settings` + +Data type: `Optional[Hash]` + +Hash containing settings for downloading modules from the Puppet Forge + +Default value: `$r10k::params::forge_settings` + +##### `proxy` + +Data type: `Optional[String[1]]` + +String containing proxy setting for r10k.yaml + +Default value: `$r10k::params::proxy` + +##### `pool_size` + +Data type: `Optional[Integer[1]]` + +Integer defining how many threads should be spawn while updating modules + +Default value: `$r10k::params::pool_size` + +##### `remote` Data type: `Any` -Default value: `$r10k::params::r10k_cache_dir` +Default value: `$r10k::params::remote` ##### `configfile` @@ -131,7 +185,7 @@ Default value: `$r10k::params::modulepath` ##### `manage_modulepath` -Data type: `Any` +Data type: `Boolean` @@ -147,7 +201,7 @@ Default value: `$r10k::params::manage_ruby_dependency` ##### `r10k_basedir` -Data type: `Any` +Data type: `Stdlib::Absolutepath` @@ -193,22 +247,6 @@ Data type: `Any` Default value: `$r10k::params::mcollective` -##### `manage_configfile_symlink` - -Data type: `Any` - - - -Default value: `$r10k::params::manage_configfile_symlink` - -##### `configfile_symlink` - -Data type: `Any` - - - -Default value: `$r10k::params::configfile_symlink` - ##### `git_settings` Data type: `Optional[Hash]` @@ -217,14 +255,6 @@ Data type: `Optional[Hash]` Default value: `$r10k::params::git_settings` -##### `forge_settings` - -Data type: `Optional[Hash]` - - - -Default value: `$r10k::params::forge_settings` - ##### `deploy_settings` Data type: `Hash` @@ -241,22 +271,6 @@ Data type: `Any` Default value: `$r10k::params::root_user` -##### `proxy` - -Data type: `Optional[String[1]]` - - - -Default value: `$r10k::params::proxy` - -##### `pool_size` - -Data type: `Optional[Integer[1]]` - - - -Default value: `$r10k::params::pool_size` - ##### `gem_source` Data type: `Optional[String[1]]` @@ -273,14 +287,6 @@ Data type: `Any` Default value: `$r10k::params::root_group` -##### `postrun` - -Data type: `Optional[Array[String[1]]]` - - - -Default value: `undef` - ##### `include_prerun_command` Data type: `Boolean` @@ -297,206 +303,7 @@ Data type: `Boolean` Default value: `false` -### `r10k::config` - -== Class: r10k::config - -Set up the root r10k config file (/etc/r10k.yaml). - -=== Parameters - -* [*cachedir*] - Path to a directory to be used by r10k for caching data. - Default: /var/cache/r10k -* [*sources*] - Hash containing data sources to be used by r10k to create dynamic Puppet - environments. Default: {} -* [*postrun*] - **Optional:** Array containing the parts of a system call. - Example: ['/usr/bin/curl', '-F', 'deploy=done', 'http://my-app.site/endpoint'] - Default: undef -* [*manage_configfile_symlink*] - Boolean to determine if a symlink to the r10k config file is to be managed. - Default: false -* [*configfile_symlink*] - Location of symlink that points to configfile. Default: /etc/r10k.yaml -* [*forge_settings*] - Hash containing settings for downloading modules from the Puppet Forge. -* [*proxy*] - String containing proxy setting for r10k.yaml. - Default: undef -* [*pool_size*] - Integer defining how many threads should be spawn while updating modules. Only available for r10k >= 3.3.0. - Default: undef - -=== Examples - - class { 'r10k::config': - sources => { - 'somename' => { - 'remote' => 'ssh://git@github.com/someuser/somerepo.git', - 'basedir' => "${::settings::confdir}/environments" - }, - 'someothername' => { - 'remote' => 'ssh://git@github.com/someuser/someotherrepo.git', - 'basedir' => '/some/other/basedir' - }, - }, - } - -== Documentation - -* https://github.com/adrienthebo/r10k#dynamic-environment-configuration - -=== Authors - -Charlie Sharpsteen -Zack Smith - -#### Parameters - -The following parameters are available in the `r10k::config` class: - -* [`configfile`](#-r10k--config--configfile) -* [`cachedir`](#-r10k--config--cachedir) -* [`sources`](#-r10k--config--sources) -* [`modulepath`](#-r10k--config--modulepath) -* [`remote`](#-r10k--config--remote) -* [`manage_modulepath`](#-r10k--config--manage_modulepath) -* [`r10k_basedir`](#-r10k--config--r10k_basedir) -* [`manage_configfile_symlink`](#-r10k--config--manage_configfile_symlink) -* [`configfile_symlink`](#-r10k--config--configfile_symlink) -* [`git_settings`](#-r10k--config--git_settings) -* [`forge_settings`](#-r10k--config--forge_settings) -* [`deploy_settings`](#-r10k--config--deploy_settings) -* [`postrun`](#-r10k--config--postrun) -* [`root_user`](#-r10k--config--root_user) -* [`root_group`](#-r10k--config--root_group) -* [`puppetconf_path`](#-r10k--config--puppetconf_path) -* [`proxy`](#-r10k--config--proxy) -* [`pool_size`](#-r10k--config--pool_size) - -##### `configfile` - -Data type: `Any` - - - -Default value: `$r10k::params::r10k_config_file` - -##### `cachedir` - -Data type: `Any` - - - -Default value: `$r10k::params::r10k_cache_dir` - -##### `sources` - -Data type: `Optional[Hash]` - - - -Default value: `$r10k::params::sources` - -##### `modulepath` - -Data type: `Any` - - - -Default value: `$r10k::params::modulepath` - -##### `remote` - -Data type: `Any` - - - -Default value: `$r10k::params::remote` - -##### `manage_modulepath` - -Data type: `Boolean` - - - -Default value: `$r10k::params::manage_modulepath` - -##### `r10k_basedir` - -Data type: `Stdlib::Absolutepath` - - - -Default value: `$r10k::params::r10k_basedir` - -##### `manage_configfile_symlink` - -Data type: `Boolean` - - - -Default value: `$r10k::params::manage_configfile_symlink` - -##### `configfile_symlink` - -Data type: `Stdlib::Absolutepath` - - - -Default value: `$r10k::params::configfile_symlink` - -##### `git_settings` - -Data type: `Optional[Hash]` - - - -Default value: `$r10k::params::git_settings` - -##### `forge_settings` - -Data type: `Optional[Hash]` - - - -Default value: `$r10k::params::forge_settings` - -##### `deploy_settings` - -Data type: `Hash` - - - -Default value: `$r10k::params::deploy_settings` - -##### `postrun` - -Data type: `Optional[Array[String[1]]]` - - - -Default value: `$r10k::params::postrun` - -##### `root_user` - -Data type: `Any` - - - -Default value: `$r10k::params::root_user` - -##### `root_group` - -Data type: `Any` - - - -Default value: `$r10k::params::root_group` - -##### `puppetconf_path` +##### `puppetconf_path` Data type: `Stdlib::Absolutepath` @@ -504,22 +311,6 @@ Data type: `Stdlib::Absolutepath` Default value: `$r10k::params::puppetconf_path` -##### `proxy` - -Data type: `Optional[String[1]]` - - - -Default value: `$r10k::params::proxy` - -##### `pool_size` - -Data type: `Optional[Integer[1]]` - - - -Default value: `$r10k::params::pool_size` - ### `r10k::install` This class is used by the ruby or pe_ruby class diff --git a/manifests/config.pp b/manifests/config.pp index 367a5518..fcb97e53 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,132 +1,70 @@ -# == Class: r10k::config # -# Set up the root r10k config file (/etc/r10k.yaml). +# @summary Set up the root r10k config file (/etc/r10k.yaml). # -# === Parameters +# @see https://github.com/adrienthebo/r10k#dynamic-environment-configuration # -# * [*cachedir*] -# Path to a directory to be used by r10k for caching data. -# Default: /var/cache/r10k -# * [*sources*] -# Hash containing data sources to be used by r10k to create dynamic Puppet -# environments. Default: {} -# * [*postrun*] -# **Optional:** Array containing the parts of a system call. -# Example: ['/usr/bin/curl', '-F', 'deploy=done', 'http://my-app.site/endpoint'] -# Default: undef -# * [*manage_configfile_symlink*] -# Boolean to determine if a symlink to the r10k config file is to be managed. -# Default: false -# * [*configfile_symlink*] -# Location of symlink that points to configfile. Default: /etc/r10k.yaml -# * [*forge_settings*] -# Hash containing settings for downloading modules from the Puppet Forge. -# * [*proxy*] -# String containing proxy setting for r10k.yaml. -# Default: undef -# * [*pool_size*] -# Integer defining how many threads should be spawn while updating modules. Only available for r10k >= 3.3.0. -# Default: undef +# @api private # -# === Examples +# @author Charlie Sharpsteen +# @author Zack Smith # -# class { 'r10k::config': -# sources => { -# 'somename' => { -# 'remote' => 'ssh://git@github.com/someuser/somerepo.git', -# 'basedir' => "${::settings::confdir}/environments" -# }, -# 'someothername' => { -# 'remote' => 'ssh://git@github.com/someuser/someotherrepo.git', -# 'basedir' => '/some/other/basedir' -# }, -# }, -# } -# -# == Documentation -# -# * https://github.com/adrienthebo/r10k#dynamic-environment-configuration -# -# === Authors -# -# Charlie Sharpsteen -# Zack Smith -class r10k::config ( - $configfile = $r10k::params::r10k_config_file, - $cachedir = $r10k::params::r10k_cache_dir, - Optional[Hash] $sources = $r10k::params::sources, - $modulepath = $r10k::params::modulepath, - $remote = $r10k::params::remote, - Boolean $manage_modulepath = $r10k::params::manage_modulepath, - Stdlib::Absolutepath $r10k_basedir = $r10k::params::r10k_basedir, - Boolean $manage_configfile_symlink = $r10k::params::manage_configfile_symlink, - Stdlib::Absolutepath $configfile_symlink = $r10k::params::configfile_symlink, - Optional[Hash] $git_settings = $r10k::params::git_settings, - Optional[Hash] $forge_settings = $r10k::params::forge_settings, - Hash $deploy_settings = $r10k::params::deploy_settings, - Optional[Array[String[1]]] $postrun = $r10k::params::postrun, - $root_user = $r10k::params::root_user, - $root_group = $r10k::params::root_group, - Stdlib::Absolutepath $puppetconf_path = $r10k::params::puppetconf_path, - Optional[String[1]] $proxy = $r10k::params::proxy, - Optional[Integer[1]] $pool_size = $r10k::params::pool_size, -) inherits r10k::params { - if $sources == undef { +class r10k::config { + if $r10k::sources == undef { $r10k_sources = { 'puppet' => { - 'basedir' => $r10k_basedir, - 'remote' => $remote, + 'basedir' => $r10k::r10k_basedir, + 'remote' => $r10k::remote, }, } $source_keys = keys($r10k_sources) } else { - $r10k_sources = $sources + $r10k_sources = $r10k::sources $source_keys = keys($r10k_sources) } - if $configfile == '/etc/puppetlabs/r10k/r10k.yaml' { + if $r10k::configfile == '/etc/puppetlabs/r10k/r10k.yaml' { file { '/etc/puppetlabs/r10k': ensure => 'directory', - owner => $root_user, - group => $root_group, + owner => $r10k::root_user, + group => $r10k::root_group, mode => '0755', } } $config = { - 'pool_size' => $pool_size, - 'proxy' => $proxy, - 'forge' => $forge_settings, - 'git' => $git_settings, - 'deploy' => $deploy_settings, - 'cachedir' => $cachedir, - 'postrun' => $postrun, + 'pool_size' => $r10k::pool_size, + 'proxy' => $r10k::proxy, + 'forge' => $r10k::forge_settings, + 'git' => $r10k::git_settings, + 'deploy' => $r10k::deploy_settings, + 'cachedir' => $r10k::cachedir, + 'postrun' => $r10k::postrun, 'sources' => $r10k_sources, }.delete_undef_values file { 'r10k.yaml': ensure => file, - owner => $root_user, - group => $root_group, + owner => $r10k::root_user, + group => $r10k::root_group, mode => '0644', - path => $configfile, + path => $r10k::configfile, content => stdlib::to_yaml($config), } - if $manage_configfile_symlink { + if $r10k::manage_configfile_symlink { file { 'symlink_r10k.yaml': ensure => 'link', - path => $configfile_symlink, - target => $configfile, + path => $r10k::configfile_symlink, + target => $r10k::configfile, } } - if $manage_modulepath { + if $r10k::manage_modulepath { ini_setting { 'R10k Modulepath': ensure => present, - path => "${puppetconf_path}/puppet.conf", + path => "${r10k::puppetconf_path}/puppet.conf", section => 'main', setting => 'modulepath', - value => $modulepath, + value => $r10k::modulepath, } } } diff --git a/manifests/init.pp b/manifests/init.pp index 6b4e79a0..f4bbf4bf 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,22 +1,31 @@ -# This class configures r10k +# @summary This class configures r10k +# +# @param cachedir Path to a directory to be used by r10k for caching data +# @param sources Hash containing data sources to be used by r10k to create dynamic Puppet environments +# @param postrun Array containing the parts of a system call Example: ['/usr/bin/curl', '-F', 'deploy=done', 'http://my-app.site/endpoint'] +# @param manage_configfile_symlink determine if a symlink to the r10k config file is to be managed +# @param configfile_symlink Location of symlink that points to configfile +# @param forge_settings Hash containing settings for downloading modules from the Puppet Forge +# @param proxy String containing proxy setting for r10k.yaml +# @param pool_size Integer defining how many threads should be spawn while updating modules class r10k ( $remote = $r10k::params::remote, - $sources = $r10k::params::sources, + Optional[Hash] $sources = $r10k::params::sources, $cachedir = $r10k::params::r10k_cache_dir, $configfile = $r10k::params::r10k_config_file, $version = $r10k::params::version, $puppet_master = $r10k::params::puppet_master, $modulepath = $r10k::params::modulepath, - $manage_modulepath = $r10k::params::manage_modulepath, + Boolean $manage_modulepath = $r10k::params::manage_modulepath, Enum['include','declare','ignore'] $manage_ruby_dependency = $r10k::params::manage_ruby_dependency, - $r10k_basedir = $r10k::params::r10k_basedir, + Stdlib::Absolutepath $r10k_basedir = $r10k::params::r10k_basedir, $package_name = $r10k::params::package_name, $provider = $r10k::params::provider, $gentoo_keywords = $r10k::params::gentoo_keywords, $install_options = $r10k::params::install_options, $mcollective = $r10k::params::mcollective, - $manage_configfile_symlink = $r10k::params::manage_configfile_symlink, - $configfile_symlink = $r10k::params::configfile_symlink, + Boolean $manage_configfile_symlink = $r10k::params::manage_configfile_symlink, + Stdlib::Absolutepath $configfile_symlink = $r10k::params::configfile_symlink, Optional[Hash] $git_settings = $r10k::params::git_settings, Optional[Hash] $forge_settings = $r10k::params::forge_settings, Hash $deploy_settings = $r10k::params::deploy_settings, @@ -28,6 +37,7 @@ Optional[Array[String[1]]] $postrun = undef, Boolean $include_prerun_command = false, Boolean $include_postrun_command = false, + Stdlib::Absolutepath $puppetconf_path = $r10k::params::puppetconf_path, ) inherits r10k::params { # Check if user is declaring both classes # Other classes like r10k::webhook is supported but @@ -56,25 +66,7 @@ puppet_master => $puppet_master, } - class { 'r10k::config': - cachedir => $cachedir, - configfile => $configfile, - sources => $sources, - modulepath => $modulepath, - remote => $remote, - manage_modulepath => $manage_modulepath, - r10k_basedir => $r10k_basedir, - manage_configfile_symlink => $manage_configfile_symlink, - configfile_symlink => $configfile_symlink, - git_settings => $git_settings, - forge_settings => $forge_settings, - deploy_settings => $deploy_settings, - postrun => $postrun, - root_user => $root_user, - root_group => $root_group, - proxy => $proxy, - pool_size => $pool_size, - } + contain r10k::config if $mcollective { class { 'r10k::mcollective': }