Puppet Class: psick::puppet::gems

Defined in:
manifests/puppet/gems.pp

Overview

This class installs the gems needed to run Puppet with this control-repo It can be also be used to install any gem on any gem environment (Puppet, PuppetServer, System, RBenv…).

Examples:

Install under rbenv environment gems needed for CI tests:

psick::puppet::gems::default_set: citest
psick::puppet::gems::install_puppet_gems: false
psick::puppet::gems::install_rbenv_gems: true

Install under system, puppet and puppet server environment

gems needed for server. Add a specific gem for puppetserver only
  psick::puppet::gems::default_set: 'master
  psick::puppet::gems::install_puppet_gems: true
  psick::puppet::gems::install_puppetserver_gems: true
  psick::puppet::gems::install_system_gems: true
  psick::puppet::gems::additional_puppetserver_gems:
    - hiera-mysql

Parameters:

  • ensure (Enum['present','absent']) (defaults to: 'present')

    Set status of managed resources

  • default_set (Enum['none','client','master','developer','citest','cideploy','integration']) (defaults to: 'none')

    Define a set of default gems to install for different use cases. Possible values: ‘none’,‘client’,‘master’,‘developer’,‘citest’, ‘cideploy’,‘integration’. Gems defined here are installed under all the environments set by install_*_gems params.

  • install_gems (Array) (defaults to: [])

    Array of additional custom gems to install under all the environments set by install_*_gems params.

  • install_options (Array) (defaults to: [])

    Optional optional to add to the package provider when installing gems

  • install_system_gems (Boolean) (defaults to: false)

    Manage installation of gems using system’s gem

  • install_puppet_gems (Boolean) (defaults to: true)

    Manage installation of gems using Puppet’s gem

  • install_puppetserver_gems (Boolean) (defaults to: false)

    Manage installation of gems using Puppetserver’s gem

  • install_rbenv_gems (Boolean) (defaults to: false)

    Manage installation of gems under rbenv (requires jdowning/rbenv or compatible module)

  • install_chruby_gems (Boolean) (defaults to: false)

    Manage installation of gems under chruby (uses psick::chruby profile

  • additional_system_gems (Array) (defaults to: [])

    Array of additional gems to install using system’s gem

  • additional_puppet_gems (Array) (defaults to: [])

    Array of additional gems to install using Puppet’s gem

  • additional_puppetserver_gems (Array) (defaults to: [])

    Array of additional gems to install using Puppetserver’s gem

  • additional_rbenv_gems (Array) (defaults to: [])

    Array of additional gems to install under rbenv

  • additional_chruby_gems (Array) (defaults to: [])

    Array of additional gems to install under chruby

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

    Ruby version to use under rbenv. Default is from $::psick::ruby::rbenv::default_ruby_version

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

    Ruby version to use under chruby. Default is from $::psick::chruby::default_ruby_version

  • auto_prereq (Boolean) (defaults to: $psick::auto_prereq)

    If to automatically install eventual dependencies required by this class. Set to false if you have problems with duplicated resources. If so, you’ll need to ensure the needed prerequisites are present.

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

    If to actually manage any resource in this class. If false no resource is managed.

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

    If to use the noop() function for all the resources provided by this class. If this is true the noop function is called with $noop_value argument. This overrides any other noop setting (either set on client’s puppet.conf or by noop() function in main psick class).

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

    The value to pass to noop() function if noop_manage is true. It applies to all the resources (and classes) declared in this class If true: noop metaparamenter is set to true, resources are not applied If false: noop metaparameter is set to false, and any eventual noop setting is overridden: resources are always applied.



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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'manifests/puppet/gems.pp', line 61

class psick::puppet::gems (
  Enum['present','absent'] $ensure     = 'present',
  Enum['none','client','master','developer','citest','cideploy','integration'] $default_set = 'none',
  Array $install_gems                  = [],
  Array $install_options               = [],
  Boolean $install_system_gems         = false,
  Boolean $install_puppet_gems         = true,
  Boolean $install_puppetserver_gems   = false,
  Boolean $install_rbenv_gems          = false,
  Boolean $install_chruby_gems         = false,
  Array $additional_system_gems        = [],
  Array $additional_puppet_gems        = [],
  Array $additional_puppetserver_gems  = [],
  Array $additional_rbenv_gems         = [],
  Array $additional_chruby_gems        = [],
  Optional[String] $rbenv_ruby_version  = undef,
  Optional[String] $chruby_ruby_version = undef,
  Boolean $auto_prereq             = $psick::auto_prereq,
  Boolean $manage                  = $psick::manage,
  Boolean $noop_manage             = $psick::noop_manage,
  Boolean $noop_value              = $psick::noop_value,
) {
  if $manage {
    if $noop_manage {
      noop($noop_value)
    }

    $minimal_gems = ['r10k','hiera-eyaml','deep_merge']
    $minimal_test_gems = ['puppet-lint','rspec-puppet','rake','bundler','simplecov','minitest','puppetlabs_spec_helper','yaml-lint'] # lint:ignore:140chars
    $default_gems = $default_set ? {
      'none'      => [],
      'client'    => [],
      'master'    => $minimal_gems,
      'cideploy'  => $minimal_gems + $minimal_test_gems,
      'citest'    => $minimal_gems + $minimal_test_gems,
      'integration' => $minimal_gems + $minimal_test_gems + ['beaker','beaker-rspec','beaker-puppet_install_helper'],
      'developer' => $minimal_gems + $minimal_test_gems + ['puppet-debug','puppet-blacksmith','puppet-ghostbuster'],
    }
    $all_gems = $default_gems + $install_gems
    if $install_system_gems {
      if $auto_prereq {
        include psick::ruby
      }
      $system_gems = $all_gems + $additional_system_gems
      $system_gems.each | $gem | {
        package { $gem:
          ensure          => $ensure,
          install_options => $install_options,
          provider        => 'gem',
          require         => Class['psick::ruby'],
        }
      }
    }
    if $install_puppet_gems {
      if $auto_prereq {
        include psick::ruby::buildgems
      }
      $puppet_gems = $all_gems + $additional_puppet_gems
      $puppet_gems.each | $gem | {
        if !defined(Class['r10k']) {
          package { "puppet_${gem}":
            ensure          => $ensure,
            name            => $gem,
            install_options => $install_options,
            provider        => 'puppet_gem',
            require         => Class['psick::ruby::buildgems'],
          }
        }
      }
    }
    if $install_puppetserver_gems {
      $puppetserver_gems = $all_gems + $additional_puppetserver_gems
      $puppetserver_gems.each | $gem | {
        package { "puppetserver_${gem}":
          ensure          => $ensure,
          name            => $gem,
          install_options => $install_options,
          provider        => 'puppetserver_gem',
        }
      }
    }
    if $install_rbenv_gems {
      if $auto_prereq {
        include psick::ruby::rbenv
      }
      $rbenv_require = $auto_prereq ? {
        true  => Class['psick::ruby::rbenv'],
        false => undef,
      }
      $rbenv_gems = $all_gems + $additional_rbenv_gems
      $rbenv_gems.each | $gem | {
        # bundler gem already installed by rbenv module
        if $gem != 'bundler' {
          rbenv::gem { $gem:
            ruby_version => pick($rbenv_ruby_version,$psick::ruby::rbenv::default_ruby_version),
            skip_docs    => true,
            require      => $rbenv_require,
          }
        }
      }
    }
    if $install_chruby_gems {
      if $auto_prereq {
        include psick::chruby
      }
      $chruby_require = $auto_prereq ? {
        true  => Class['psick::chruby'],
        false => undef,
      }
      $chruby_gems = $all_gems + $additional_chruby_gems
      $chruby_gems.each | $gem | {
        psick::chruby::gem { $gem:
          ruby_version => pick($chruby_ruby_version,$psick::chruby::default_ruby_version),
          require      => $chruby_require,
        }
      }
    }
  }
}