Puppet Class: psick::chruby

Defined in:
manifests/chruby.pp

Summary

This psick profile manages chruby.

Overview

psick::chruby

Examples:

Include it to install chruby

include psick::chruby

Include in PSICK via hiera (yaml)

psick::profiles::linux_classes:
  chruby: psick::chruby

Set no-noop mode and enforce changes even if noop is set for the agent

psick::chruby::no_noop: true

Parameters:

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

    If to actually manage any resource in this profile or not

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

    If to automatically install eventual dependencies. Set to false if you have problems with duplicated resources, being sure that you provide the needed prerequistes.

  • no_noop (Boolean) (defaults to: false)

    Set noop metaparameter to false to all the resources of this class. This overrides any noop setting which might be in place.

  • ensure (Psick::Ensure) (defaults to: 'present')
  • version (String) (defaults to: '0.3.7')
  • default_ruby_version (String) (defaults to: '2.4.3')
  • ruby_prefix (StdLib::AbsolutePath) (defaults to: '/opt/rubies')
  • user (String) (defaults to: 'puppet')
  • group (Optional[String]) (defaults to: undef)
  • sources_root (Optional[String]) (defaults to: undef)
  • download_root (Optional[String]) (defaults to: undef)


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
# File 'manifests/chruby.pp', line 21

class psick::chruby (
  Psick::Ensure $ensure             = 'present',
  String $version                   = '0.3.7',
  String $default_ruby_version      = '2.4.3',
  StdLib::AbsolutePath $ruby_prefix = '/opt/rubies',
  String $user                      = 'puppet',
  Optional[String] $group           = undef,
  Optional[String] $sources_root    = undef,
  Optional[String] $download_root   = undef,

  Boolean         $manage           = $::psick::manage,
  Boolean         $auto_prereq      = $::psick::auto_prereq,
  Boolean         $no_noop          = false,

) {

  # We declare resources only if $manage = true
  if $manage {

    # If no_noop is set it's enforced, unless psick::noop_mode is 
    if ! $::psick::noop_mode and $no_noop {
      info('Forced no-noop mode in psick::chruby')
      noop(false)
    }

    $sources_dest = $sources_root ? {
      undef   => "${ruby_prefix}/sources",
      default => $sources_root
    }
    $download_dest = $download_root ? {
      undef   => "${ruby_prefix}/downloads",
      default => $download_root
    }
    psick::netinstall { "chruby-v${version}.tar.gz":
      destination_dir => $sources_dest,
      url             => "https://github.com/postmodern/chruby/archive/v${version}.tar.gz",
      extract_command => 'tar -zxf',
      owner           => $user,
      group           => $group,
      creates         => "${sources_dest}/chruby-${version}",
      before          => Exec['install chruby'],
    }

    exec { 'install chruby':
      cwd     => "${sources_dest}/chruby-${version}",
      command => 'make install',
      creates => '/usr/local/share/chruby',
      path    => [ '/sbin', '/usr/sbin', '/bin', '/usr/bin' ],
    }

    file { '/etc/profile.d/chruby.sh':
      ensure  => 'file',
      content => '. "/usr/local/share/chruby/chruby.sh"',
      require => Exec['install chruby'],
    }
  }
}