falkorlib 0.7.8 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/falkorlib/puppet/modules.rb +4 -4
- data/lib/falkorlib/version.rb +1 -1
- data/spec/falkorlib/puppet_modules_spec.rb +2 -2
- data/templates/puppet/modules/Gemfile +41 -6
- data/templates/puppet/modules/Rakefile +21 -6
- data/templates/puppet/modules/Vagrantfile +130 -40
- data/templates/puppet/modules/docs/vagrant.md.erb +29 -11
- data/templates/puppet/modules/manifests/common/debian.pp.erb +3 -0
- data/templates/puppet/modules/manifests/common/redhat.pp.erb +3 -0
- data/templates/puppet/modules/manifests/common.pp.erb +141 -102
- data/templates/puppet/modules/manifests/init.pp.erb +28 -25
- data/templates/puppet/modules/manifests/mydef.pp.erb +3 -0
- data/templates/puppet/modules/manifests/params.pp.erb +117 -110
- data/templates/puppet/modules/metadata.json.erb +14 -2
- data/templates/puppet/modules/mkdocs.yml.erb +11 -9
- data/templates/puppet/modules/tests/init.pp.erb +1 -1
- data/templates/puppet/modules/tests/vagrant/bootstrap.sh +229 -0
- data/templates/puppet/modules/tests/vagrant/config.yaml +51 -0
- data/templates/puppet/modules/tests/vagrant/puppet_modules_setup.rb +74 -0
- metadata +5 -3
- data/templates/puppet/modules/.vagrant_init.rb +0 -67
| @@ -1,3 +1,6 @@ | |
| 1 | 
            +
            ################################################################################
         | 
| 2 | 
            +
            # Time-stamp: <Wed 2017-08-23 15:14 svarrette>
         | 
| 3 | 
            +
            #
         | 
| 1 4 | 
             
            # File::      <tt>common.pp</tt>
         | 
| 2 5 | 
             
            # Author::    <%= config[:author] %> (<%= config[:mail] %>)
         | 
| 3 6 | 
             
            # Copyright:: Copyright (c) <%= Time.now.year %> <%= config[:author] %>
         | 
| @@ -9,119 +12,155 @@ | |
| 9 12 | 
             
            # Base class to be inherited by the other <%= config[:shortname] %> classes, containing the common code.
         | 
| 10 13 | 
             
            #
         | 
| 11 14 | 
             
            # Note: respect the Naming standard provided here[http://projects.puppetlabs.com/projects/puppet/wiki/Module_Standards]
         | 
| 12 | 
            -
             | 
| 15 | 
            +
            #
         | 
| 13 16 | 
             
            class <%= config[:shortname] %>::common {
         | 
| 14 17 |  | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 18 | 
            +
              # Load the variables used in this module. Check the params.pp file
         | 
| 19 | 
            +
              require <%= config[:shortname] %>::params
         | 
| 17 20 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
                 | 
| 24 | 
            -
             | 
| 21 | 
            +
              # Order
         | 
| 22 | 
            +
              if ($<%= config[:shortname] %>::ensure == 'present') {
         | 
| 23 | 
            +
                Group['<%= config[:shortname] %>'] -> User['<%= config[:shortname] %>'] -> Package['<%= config[:shortname] %>']
         | 
| 24 | 
            +
              }
         | 
| 25 | 
            +
              else {
         | 
| 26 | 
            +
                Package['<%= config[:shortname] %>'] -> User['<%= config[:shortname] %>'] -> Group['<%= config[:shortname] %>']
         | 
| 27 | 
            +
              }
         | 
| 25 28 |  | 
| 26 | 
            -
             | 
| 29 | 
            +
              # Prepare the user and group
         | 
| 30 | 
            +
              group { '<%= config[:shortname] %>':
         | 
| 31 | 
            +
                ensure => $<%= config[:shortname] %>::ensure,
         | 
| 32 | 
            +
                name   => <%= config[:shortname] %>::params::group,
         | 
| 33 | 
            +
                gid    => <%= config[:shortname] %>::params::gid,
         | 
| 34 | 
            +
              }
         | 
| 35 | 
            +
              user { 'munge':
         | 
| 36 | 
            +
                ensure     => $<%= config[:shortname] %>::ensure,
         | 
| 37 | 
            +
                name       => $<%= config[:shortname] %>::params::username,
         | 
| 38 | 
            +
                uid        => $<%= config[:shortname] %>::params::gid,
         | 
| 39 | 
            +
                gid        => $<%= config[:shortname] %>::params::gid,
         | 
| 40 | 
            +
                comment    => $<%= config[:shortname] %>::params::comment,
         | 
| 41 | 
            +
                home       => $<%= config[:shortname] %>::params::home,
         | 
| 42 | 
            +
                managehome => true,
         | 
| 43 | 
            +
                system     => true,
         | 
| 44 | 
            +
                shell      => $<%= config[:shortname] %>::params::shell,
         | 
| 45 | 
            +
              }
         | 
| 27 46 |  | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
                    }
         | 
| 47 | 
            +
              package { '<%= config[:shortname] %>':
         | 
| 48 | 
            +
                name    => "${<%= config[:shortname] %>::params::packagename}",
         | 
| 49 | 
            +
                ensure  => "${<%= config[:shortname] %>::ensure}",
         | 
| 50 | 
            +
              }
         | 
| 51 | 
            +
              package { $<%= config[:shortname] %>::params::extra_packages:
         | 
| 52 | 
            +
                ensure => 'present'
         | 
| 53 | 
            +
              }
         | 
| 36 54 |  | 
| 37 | 
            -
             | 
| 38 | 
            -
                    # file { "${<%= config[:shortname] %>::params::configdir}":
         | 
| 39 | 
            -
                    #     ensure => 'directory',
         | 
| 40 | 
            -
                    #     owner  => "${<%= config[:shortname] %>::params::configdir_owner}",
         | 
| 41 | 
            -
                    #     group  => "${<%= config[:shortname] %>::params::configdir_group}",
         | 
| 42 | 
            -
                    #     mode   => "${<%= config[:shortname] %>::params::configdir_mode}",
         | 
| 43 | 
            -
                    #     require => Package['<%= config[:shortname] %>'],
         | 
| 44 | 
            -
                    # }
         | 
| 45 | 
            -
                    # Regular version using file resource
         | 
| 46 | 
            -
                    file { '<%= config[:shortname] %>.conf':
         | 
| 47 | 
            -
                        path    => "${<%= config[:shortname] %>::params::configfile}",
         | 
| 48 | 
            -
                        owner   => "${<%= config[:shortname] %>::params::configfile_owner}",
         | 
| 49 | 
            -
                        group   => "${<%= config[:shortname] %>::params::configfile_group}",
         | 
| 50 | 
            -
                        mode    => "${<%= config[:shortname] %>::params::configfile_mode}",
         | 
| 51 | 
            -
                        ensure  => "${<%= config[:shortname] %>::ensure}",
         | 
| 52 | 
            -
                        #content => template("<%= config[:shortname] %>/<%= config[:shortname] %>conf.erb"),
         | 
| 53 | 
            -
                        #source => "puppet:///modules/<%= config[:shortname] %>/<%= config[:shortname] %>.conf",
         | 
| 54 | 
            -
                        #notify  => Service['<%= config[:shortname] %>'],
         | 
| 55 | 
            -
                        require => [
         | 
| 56 | 
            -
                                    #File["${<%= config[:shortname] %>::params::configdir}"],
         | 
| 57 | 
            -
                                    Package['<%= config[:shortname] %>']
         | 
| 58 | 
            -
                                    ],
         | 
| 59 | 
            -
                    }
         | 
| 55 | 
            +
              if $<%= config[:shortname] %>::ensure == 'present' {
         | 
| 60 56 |  | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
                    #     require => Package['<%= config[:shortname] %>'],
         | 
| 70 | 
            -
                    # }
         | 
| 71 | 
            -
                    # # Populate the configuration file
         | 
| 72 | 
            -
                    # concat::fragment { "${<%= config[:shortname] %>::params::configfile}_header":
         | 
| 73 | 
            -
                    #     target  => "${<%= config[:shortname] %>::params::configfile}",
         | 
| 74 | 
            -
                    #     ensure  => "${<%= config[:shortname] %>::ensure}",
         | 
| 75 | 
            -
                    #     content => template("<%= config[:shortname] %>/<%= config[:shortname] %>_header.conf.erb"),
         | 
| 76 | 
            -
                    #     #source => "puppet:///modules/<%= config[:shortname] %>/<%= config[:shortname] %>_header.conf",
         | 
| 77 | 
            -
                    #     order   => '01',
         | 
| 78 | 
            -
                    # }
         | 
| 79 | 
            -
                    # concat::fragment { "${<%= config[:shortname] %>::params::configfile}_footer":
         | 
| 80 | 
            -
                    #     target  => "${<%= config[:shortname] %>::params::configfile}",
         | 
| 81 | 
            -
                    #     ensure  => "${<%= config[:shortname] %>::ensure}",
         | 
| 82 | 
            -
                    #     content => template("<%= config[:shortname] %>/<%= config[:shortname] %>_footer.conf.erb"),
         | 
| 83 | 
            -
                    #     #source => "puppet:///modules/<%= config[:shortname] %>/<%= config[:shortname] %>_footer.conf",
         | 
| 84 | 
            -
                    #     order   => '99',
         | 
| 85 | 
            -
                    # }
         | 
| 57 | 
            +
                # Prepare the log directory
         | 
| 58 | 
            +
                file { "${<%= config[:shortname] %>::params::logdir}":
         | 
| 59 | 
            +
                  ensure => 'directory',
         | 
| 60 | 
            +
                  owner  => "${<%= config[:shortname] %>::params::logdir_owner}",
         | 
| 61 | 
            +
                  group  => "${<%= config[:shortname] %>::params::logdir_group}",
         | 
| 62 | 
            +
                  mode   => "${<%= config[:shortname] %>::params::logdir_mode}",
         | 
| 63 | 
            +
                  require => Package['<%= config[:shortname] %>'],
         | 
| 64 | 
            +
                }
         | 
| 86 65 |  | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 66 | 
            +
                # Configuration file
         | 
| 67 | 
            +
                file { "${<%= config[:shortname] %>::params::configdir}":
         | 
| 68 | 
            +
                  ensure => 'directory',
         | 
| 69 | 
            +
                  owner  => "${<%= config[:shortname] %>::params::configdir_owner}",
         | 
| 70 | 
            +
                  group  => "${<%= config[:shortname] %>::params::configdir_group}",
         | 
| 71 | 
            +
                  mode   => "${<%= config[:shortname] %>::params::configdir_mode}",
         | 
| 72 | 
            +
                  require => Package['<%= config[:shortname] %>'],
         | 
| 73 | 
            +
                }
         | 
| 74 | 
            +
                # Regular version using file resource
         | 
| 75 | 
            +
                file { '<%= config[:shortname] %>.conf':
         | 
| 76 | 
            +
                  ensure  => "${<%= config[:shortname] %>::ensure}",
         | 
| 77 | 
            +
                  path    => "${<%= config[:shortname] %>::params::configfile}",
         | 
| 78 | 
            +
                  owner   => "${<%= config[:shortname] %>::params::configfile_owner}",
         | 
| 79 | 
            +
                  group   => "${<%= config[:shortname] %>::params::configfile_group}",
         | 
| 80 | 
            +
                  mode    => "${<%= config[:shortname] %>::params::configfile_mode}",
         | 
| 81 | 
            +
                  #content => template("<%= config[:shortname] %>/<%= config[:shortname] %>conf.erb"),
         | 
| 82 | 
            +
                  #source => "puppet:///modules/<%= config[:shortname] %>/<%= config[:shortname] %>.conf",
         | 
| 83 | 
            +
                  #notify  => Service['<%= config[:shortname] %>'],
         | 
| 84 | 
            +
                  require => [
         | 
| 85 | 
            +
                    #File["${<%= config[:shortname] %>::params::configdir}"],
         | 
| 86 | 
            +
                    Package['<%= config[:shortname] %>']
         | 
| 87 | 
            +
                  ],
         | 
| 88 | 
            +
                }
         | 
| 94 89 |  | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 90 | 
            +
                # # Concat version -- see https://forge.puppetlabs.com/puppetlabs/concat
         | 
| 91 | 
            +
                # include concat::setup
         | 
| 92 | 
            +
                # concat { "${<%= config[:shortname] %>::params::configfile}":
         | 
| 93 | 
            +
                  #     warn    => false,
         | 
| 94 | 
            +
                  #     owner   => "${<%= config[:shortname] %>::params::configfile_owner}",
         | 
| 95 | 
            +
                  #     group   => "${<%= config[:shortname] %>::params::configfile_group}",
         | 
| 96 | 
            +
                  #     mode    => "${<%= config[:shortname] %>::params::configfile_mode}",
         | 
| 97 | 
            +
                  #     #notify  => Service['<%= config[:shortname] %>'],
         | 
| 98 | 
            +
                  #     require => Package['<%= config[:shortname] %>'],
         | 
| 99 | 
            +
                  # }
         | 
| 100 | 
            +
                # # Populate the configuration file
         | 
| 101 | 
            +
                # concat::fragment { "${<%= config[:shortname] %>::params::configfile}_header":
         | 
| 102 | 
            +
                  #     ensure  => "${<%= config[:shortname] %>::ensure}",
         | 
| 103 | 
            +
                  #     target  => "${<%= config[:shortname] %>::params::configfile}",
         | 
| 104 | 
            +
                  #     content => template("<%= config[:shortname] %>/<%= config[:shortname] %>_header.conf.erb"),
         | 
| 105 | 
            +
                  #     #source => "puppet:///modules/<%= config[:shortname] %>/<%= config[:shortname] %>_header.conf",
         | 
| 106 | 
            +
                  #     order   => '01',
         | 
| 107 | 
            +
                  # }
         | 
| 108 | 
            +
                # concat::fragment { "${<%= config[:shortname] %>::params::configfile}_footer":
         | 
| 109 | 
            +
                  #     ensure  => "${<%= config[:shortname] %>::ensure}",
         | 
| 110 | 
            +
                  #     target  => "${<%= config[:shortname] %>::params::configfile}",
         | 
| 111 | 
            +
                  #     content => template("<%= config[:shortname] %>/<%= config[:shortname] %>_footer.conf.erb"),
         | 
| 112 | 
            +
                  #     #source => "puppet:///modules/<%= config[:shortname] %>/<%= config[:shortname] %>_footer.conf",
         | 
| 113 | 
            +
                  #     order   => '99',
         | 
| 114 | 
            +
                  # }
         | 
| 105 115 |  | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
                        hasstatus  => "${<%= config[:shortname] %>::params::hasstatus}",
         | 
| 113 | 
            -
                        require    => [
         | 
| 114 | 
            -
                                       Package['<%= config[:shortname] %>'],
         | 
| 115 | 
            -
                                       File["${<%= config[:shortname] %>::params::configfile_init}"]
         | 
| 116 | 
            -
                                       ],
         | 
| 117 | 
            -
                        subscribe  => File['<%= config[:shortname] %>.conf'],
         | 
| 118 | 
            -
                    }
         | 
| 116 | 
            +
                # PID file directory
         | 
| 117 | 
            +
                file { "${<%= config[:shortname] %>::params::piddir}":
         | 
| 118 | 
            +
                  ensure  => 'directory',
         | 
| 119 | 
            +
                  owner   => "${<%= config[:shortname] %>::params::piddir_user}",
         | 
| 120 | 
            +
                  group   => "${<%= config[:shortname] %>::params::piddir_group}",
         | 
| 121 | 
            +
                  mode    => "${<%= config[:shortname] %>::params::piddir_mode}",
         | 
| 119 122 | 
             
                }
         | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 123 | 
            +
              }
         | 
| 124 | 
            +
              else
         | 
| 125 | 
            +
              {
         | 
| 126 | 
            +
                # Here $<%= config[:shortname] %>::ensure is 'absent'
         | 
| 127 | 
            +
                file {
         | 
| 128 | 
            +
                  [
         | 
| 129 | 
            +
                    $<%= config[:shortname] %>::params::configdir,
         | 
| 130 | 
            +
                    $<%= config[:shortname] %>::params::logdir,
         | 
| 131 | 
            +
                    $<%= config[:shortname] %>::params::piddir,
         | 
| 132 | 
            +
                  ]:
         | 
| 133 | 
            +
                    ensure => $<%= config[:shortname] %>::ensure,
         | 
| 134 | 
            +
                    force  => true,
         | 
| 135 | 
            +
                }
         | 
| 136 | 
            +
              }
         | 
| 137 | 
            +
                # Sysconfig / default daemon directory
         | 
| 138 | 
            +
                file { "${<%= config[:shortname] %>::params::default_sysconfig}":
         | 
| 139 | 
            +
                  ensure  => $<%= config[:shortname] %>::ensure,
         | 
| 140 | 
            +
                  owner   => $<%= config[:shortname] %>::params::configfile_owner,
         | 
| 141 | 
            +
                  group   => $<%= config[:shortname] %>::params::configfile_group,
         | 
| 142 | 
            +
                  mode    => '0755',
         | 
| 143 | 
            +
                  #content => template("<%= config[:shortname] %>/default/<%= config[:shortname] %>.erb"),
         | 
| 144 | 
            +
                  #source => "puppet:///modules/<%= config[:shortname] %>/default/<%= config[:shortname] %>.conf",
         | 
| 145 | 
            +
                  notify  =>  Service['<%= config[:shortname] %>'],
         | 
| 146 | 
            +
                  require =>  Package['<%= config[:shortname] %>']
         | 
| 124 147 | 
             
                }
         | 
| 125 148 |  | 
| 126 | 
            -
             | 
| 149 | 
            +
              service { '<%= config[:shortname] %>':
         | 
| 150 | 
            +
                ensure     => ($<%= config[:shortname] %>::ensure == 'present'),
         | 
| 151 | 
            +
                name       => "${<%= config[:shortname] %>::params::servicename}",
         | 
| 152 | 
            +
                enable     => ($<%= config[:shortname] %>::ensure == 'present'),
         | 
| 153 | 
            +
                pattern    => "${<%= config[:shortname] %>::params::processname}",
         | 
| 154 | 
            +
                hasrestart => "${<%= config[:shortname] %>::params::hasrestart}",
         | 
| 155 | 
            +
                hasstatus  => "${<%= config[:shortname] %>::params::hasstatus}",
         | 
| 156 | 
            +
                require    => [
         | 
| 157 | 
            +
                  Package['<%= config[:shortname] %>'],
         | 
| 158 | 
            +
                  File[$<%= config[:shortname] %>::params::configdir],
         | 
| 159 | 
            +
                  File[$<%= config[:shortname] %>::params::logdir],
         | 
| 160 | 
            +
                  File[$<%= config[:shortname] %>::params::piddir],
         | 
| 161 | 
            +
                  File[$<%= config[:shortname] %>::params::configfile_init]
         | 
| 162 | 
            +
                ],
         | 
| 163 | 
            +
                subscribe  => File['<%= config[:shortname] %>.conf'],
         | 
| 164 | 
            +
              }
         | 
| 127 165 |  | 
| 166 | 
            +
            }
         | 
| @@ -1,63 +1,66 @@ | |
| 1 | 
            +
            ################################################################################
         | 
| 2 | 
            +
            # Time-stamp: <Wed 2017-08-23 14:49 svarrette>
         | 
| 3 | 
            +
            #
         | 
| 1 4 | 
             
            # File::      <tt>init.pp</tt>
         | 
| 2 5 | 
             
            # Author::    <%= config[:author] %> (<%= config[:mail] %>)
         | 
| 3 6 | 
             
            # Copyright:: Copyright (c) <%= Time.now.year %> <%= config[:author] %>
         | 
| 4 7 | 
             
            # License::   <%= config[:license].capitalize %>
         | 
| 5 8 | 
             
            #
         | 
| 6 9 | 
             
            # ------------------------------------------------------------------------------
         | 
| 7 | 
            -
            #  | 
| 10 | 
            +
            # == Class: <%= config[:shortname] %>
         | 
| 8 11 | 
             
            #
         | 
| 9 12 | 
             
            # <%= config[:summary] %>
         | 
| 10 13 | 
             
            #
         | 
| 11 | 
            -
            # == Parameters:
         | 
| 12 | 
            -
            #
         | 
| 13 | 
            -
            # $ensure:: *Default*: 'present'. Ensure the presence (or absence) of <%= config[:shortname] %>
         | 
| 14 | 
            -
            #
         | 
| 15 | 
            -
            # == Actions:
         | 
| 16 14 | 
             
            #
         | 
| 17 | 
            -
            #  | 
| 15 | 
            +
            # @param ensure [String] Default: 'present'.
         | 
| 16 | 
            +
            #          Ensure the presence (or absence) of <%= config[:shortname] %>
         | 
| 18 17 | 
             
            #
         | 
| 19 | 
            -
            #  | 
| 18 | 
            +
            # === Requires
         | 
| 20 19 | 
             
            #
         | 
| 21 20 | 
             
            # n/a
         | 
| 22 21 | 
             
            #
         | 
| 23 | 
            -
            #  | 
| 22 | 
            +
            # @example Basic instanciation
         | 
| 24 23 | 
             
            #
         | 
| 25 | 
            -
            #     include ' | 
| 24 | 
            +
            #     include '::<%= config[:shortname] %>'
         | 
| 26 25 | 
             
            #
         | 
| 27 26 | 
             
            # You can then specialize the various aspects of the configuration,
         | 
| 28 27 | 
             
            # for instance:
         | 
| 29 28 | 
             
            #
         | 
| 30 | 
            -
            #         class { ' | 
| 29 | 
            +
            #         class { '::<%= config[:shortname] %>':
         | 
| 31 30 | 
             
            #             ensure => 'present'
         | 
| 32 31 | 
             
            #         }
         | 
| 33 32 | 
             
            #
         | 
| 34 | 
            -
            #  | 
| 33 | 
            +
            # === Authors
         | 
| 35 34 | 
             
            #
         | 
| 36 | 
            -
            #  | 
| 37 | 
            -
            #  | 
| 35 | 
            +
            # The UL HPC Team <hpc-sysadmins@uni.lu> of the University of Luxembourg, in
         | 
| 36 | 
            +
            # particular
         | 
| 37 | 
            +
            # * Sebastien Varrette <Sebastien.Varrette@uni.lu>
         | 
| 38 | 
            +
            # * Valentin Plugaru   <Valentin.Plugaru@uni.lu>
         | 
| 39 | 
            +
            # * Sarah Peter        <Sarah.Peter@uni.lu>
         | 
| 40 | 
            +
            # * Hyacinthe Cartiaux <Hyacinthe.Cartiaux@uni.lu>
         | 
| 41 | 
            +
            # * Clement Parisot    <Clement.Parisot@uni.lu>
         | 
| 42 | 
            +
            # See AUTHORS for more details
         | 
| 38 43 | 
             
            #
         | 
| 44 | 
            +
            # === Warnings
         | 
| 45 | 
            +
            #
         | 
| 46 | 
            +
            # /!\ Always respect the style guide available here[http://docs.puppetlabs.com/guides/style_guide]
         | 
| 39 47 | 
             
            #
         | 
| 40 48 | 
             
            # [Remember: No empty lines between comments and class definition]
         | 
| 41 49 | 
             
            #
         | 
| 42 50 | 
             
            class <%= config[:shortname] %>(
         | 
| 43 | 
            -
                $ensure = $<%= config[:shortname] %>::params::ensure
         | 
| 51 | 
            +
                String $ensure = $<%= config[:shortname] %>::params::ensure
         | 
| 44 52 | 
             
            )
         | 
| 45 53 | 
             
            inherits <%= config[:shortname] %>::params
         | 
| 46 54 | 
             
            {
         | 
| 47 | 
            -
                 | 
| 55 | 
            +
                validate_legacy('String', 'validate_re', $ensure, ['^present', '^absent'])
         | 
| 48 56 |  | 
| 49 | 
            -
                 | 
| 50 | 
            -
                    fail("<%= config[:shortname] %> 'ensure' parameter must be set to either 'absent' or 'present'")
         | 
| 51 | 
            -
                }
         | 
| 57 | 
            +
                info ("Configuring <%= config[:shortname] %> (with ensure = ${ensure})")
         | 
| 52 58 |  | 
| 53 59 | 
             
                case $::operatingsystem {
         | 
| 54 | 
            -
                    debian | 
| 55 | 
            -
                    redhat | 
| 60 | 
            +
                    /(?i-mx:ubuntu|debian)/:        { include ::<%= config[:shortname] %>::common::debian }
         | 
| 61 | 
            +
                    /(?i-mx:centos|fedora|redhat)/: { include ::<%= config[:shortname] %>::common::redhat }
         | 
| 56 62 | 
             
                    default: {
         | 
| 57 | 
            -
                        fail("Module $module_name is not supported on $operatingsystem")
         | 
| 63 | 
            +
                        fail("Module ${module_name} is not supported on ${::operatingsystem}")
         | 
| 58 64 | 
             
                    }
         | 
| 59 65 | 
             
                }
         | 
| 60 66 | 
             
            }
         | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| @@ -1,3 +1,6 @@ | |
| 1 | 
            +
            ################################################################################
         | 
| 2 | 
            +
            # Time-stamp: <Wed 2017-08-23 14:37 svarrette>
         | 
| 3 | 
            +
            #
         | 
| 1 4 | 
             
            # File::      <tt>mydef.pp</tt>
         | 
| 2 5 | 
             
            # Author::    <%= config[:author] %> (<%= config[:mail] %>)
         | 
| 3 6 | 
             
            # Copyright:: Copyright (c) <%= Time.now.year %> <%= config[:author] %>
         | 
| @@ -1,143 +1,150 @@ | |
| 1 | 
            +
            ################################################################################
         | 
| 2 | 
            +
            # Time-stamp: <Wed 2017-08-23 15:15 svarrette>
         | 
| 3 | 
            +
            #
         | 
| 1 4 | 
             
            # File::      <tt>params.pp</tt>
         | 
| 2 5 | 
             
            # Author::    <%= config[:author] %> (<%= config[:mail] %>)
         | 
| 3 6 | 
             
            # Copyright:: Copyright (c) <%= Time.now.year %> <%= config[:author] %>
         | 
| 4 7 | 
             
            # License::   <%= config[:license].capitalize %>
         | 
| 5 8 | 
             
            #
         | 
| 6 9 | 
             
            # ------------------------------------------------------------------------------
         | 
| 7 | 
            -
            #  | 
| 10 | 
            +
            # == Class: <%= config[:shortname] %>::params
         | 
| 8 11 | 
             
            #
         | 
| 9 12 | 
             
            # In this class are defined as variables values that are used in other
         | 
| 10 | 
            -
            # <%= config[:shortname] %> classes.
         | 
| 13 | 
            +
            # <%= config[:shortname] %> classes and definitions.
         | 
| 11 14 | 
             
            # This class should be included, where necessary, and eventually be enhanced
         | 
| 12 | 
            -
            # with support for more  | 
| 15 | 
            +
            # with support for more Operating Systems.
         | 
| 13 16 | 
             
            #
         | 
| 14 17 | 
             
            # == Warnings
         | 
| 15 18 | 
             
            #
         | 
| 16 19 | 
             
            # /!\ Always respect the style guide available
         | 
| 17 20 | 
             
            # here[http://docs.puppetlabs.com/guides/style_guide]
         | 
| 18 21 | 
             
            #
         | 
| 19 | 
            -
            # The usage of a dedicated param classe is advised to better deal with
         | 
| 20 | 
            -
            # parametrized classes, see
         | 
| 21 | 
            -
            # http://docs.puppetlabs.com/guides/parameterized_classes.html
         | 
| 22 | 
            -
            #
         | 
| 23 22 | 
             
            # [Remember: No empty lines between comments and class definition]
         | 
| 24 23 | 
             
            #
         | 
| 25 24 | 
             
            class <%= config[:shortname] %>::params {
         | 
| 26 25 |  | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 26 | 
            +
              #### MODULE INTERNAL VARIABLES  #########
         | 
| 27 | 
            +
              # (Modify to adapt to unsupported OSes)
         | 
| 28 | 
            +
              #########################################
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              # ensure the presence (or absence) of <%= config[:shortname] %>
         | 
| 31 | 
            +
              $ensure = 'present'
         | 
| 31 32 |  | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 33 | 
            +
              # The Protocol used. Used by monitor and firewall class. Default is 'tcp'
         | 
| 34 | 
            +
              $protocol = 'tcp'
         | 
| 34 35 |  | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 36 | 
            +
              # The port number. Used by monitor and firewall class. The default is 22.
         | 
| 37 | 
            +
              $port = 22
         | 
| 37 38 |  | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 39 | 
            +
              # example of an array/hash variable
         | 
| 40 | 
            +
              $array_variable = []
         | 
| 41 | 
            +
              $hash_variable  = {}
         | 
| 40 42 |  | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
                $hash_variable  = {}
         | 
| 43 | 
            +
              # undef variable
         | 
| 44 | 
            +
              $undefvar = undef
         | 
| 44 45 |  | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 46 | 
            +
              ###########################################
         | 
| 47 | 
            +
              # <%= config[:shortname] %> system configs
         | 
| 48 | 
            +
              ###########################################
         | 
| 49 | 
            +
              # <%= config[:shortname] %> user / group identifiers
         | 
| 50 | 
            +
              $username = '<%= config[:shortname] %>'
         | 
| 51 | 
            +
              $uid      = 14144
         | 
| 52 | 
            +
              $group    = $username
         | 
| 53 | 
            +
              $gid      = $uid
         | 
| 54 | 
            +
              $home     = "/var/lib/${username}"
         | 
| 55 | 
            +
              $comment  = '<%= config[:shortname].capitalize %> User'
         | 
| 56 | 
            +
              $shell    = '/sbin/nologin' # or '/bin/bash'
         | 
| 47 57 |  | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
                 | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
                     | 
| 54 | 
            -
                 | 
| 55 | 
            -
                 | 
| 56 | 
            -
             | 
| 57 | 
            -
                #     /(?i-mx:centos|fedora|redhat)/ => [],
         | 
| 58 | 
            -
                #     default => []
         | 
| 59 | 
            -
                # }
         | 
| 58 | 
            +
              # <%= config[:shortname] %> packages
         | 
| 59 | 
            +
              $packagename = $::operatingsystem ? {
         | 
| 60 | 
            +
                default => '<%= config[:shortname] %>',
         | 
| 61 | 
            +
              }
         | 
| 62 | 
            +
              $extra_packages = $::operatingsystem ? {
         | 
| 63 | 
            +
                /(?i-mx:ubuntu|debian)/        => [],
         | 
| 64 | 
            +
                /(?i-mx:centos|fedora|redhat)/ => [],
         | 
| 65 | 
            +
                default => []
         | 
| 66 | 
            +
              }
         | 
| 60 67 |  | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 68 | 
            +
              # Log directory
         | 
| 69 | 
            +
              $logdir = $::operatingsystem ? {
         | 
| 70 | 
            +
                default => '/var/log/<%= config[:shortname] %>'
         | 
| 71 | 
            +
              }
         | 
| 72 | 
            +
              $logdir_mode = $::operatingsystem ? {
         | 
| 73 | 
            +
                default => '750',
         | 
| 74 | 
            +
              }
         | 
| 75 | 
            +
              $logdir_owner = $::operatingsystem ? {
         | 
| 76 | 
            +
                default => 'root',
         | 
| 77 | 
            +
              }
         | 
| 78 | 
            +
              $logdir_group = $::operatingsystem ? {
         | 
| 79 | 
            +
                default => 'adm',
         | 
| 80 | 
            +
              }
         | 
| 74 81 |  | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
                 | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
                 | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
                 | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
                 | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
                 | 
| 90 | 
            -
             | 
| 82 | 
            +
              # PID for daemons
         | 
| 83 | 
            +
              $piddir = $::operatingsystem ? {
         | 
| 84 | 
            +
                default => "/var/run/<%= config[:shortname] %>",
         | 
| 85 | 
            +
              }
         | 
| 86 | 
            +
              $piddir_mode = $::operatingsystem ? {
         | 
| 87 | 
            +
                default => '750',
         | 
| 88 | 
            +
              }
         | 
| 89 | 
            +
              $piddir_owner = $::operatingsystem ? {
         | 
| 90 | 
            +
                default => '<%= config[:shortname] %>',
         | 
| 91 | 
            +
              }
         | 
| 92 | 
            +
              $piddir_group = $::operatingsystem ? {
         | 
| 93 | 
            +
                default => 'adm',
         | 
| 94 | 
            +
              }
         | 
| 95 | 
            +
              $pidfile = $::operatingsystem ? {
         | 
| 96 | 
            +
                default => '/var/run/<%= config[:shortname] %>/<%= config[:shortname] %>.pid'
         | 
| 97 | 
            +
              }
         | 
| 91 98 |  | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 99 | 
            +
              # <%= config[:shortname] %> associated services
         | 
| 100 | 
            +
              $servicename = $::operatingsystem ? {
         | 
| 101 | 
            +
                /(?i-mx:ubuntu|debian)/ => '<%= config[:shortname] %>',
         | 
| 102 | 
            +
                default                 => '<%= config[:shortname] %>'
         | 
| 103 | 
            +
              }
         | 
| 104 | 
            +
              # used for pattern in a service ressource
         | 
| 105 | 
            +
              $processname = $::operatingsystem ? {
         | 
| 106 | 
            +
                /(?i-mx:ubuntu|debian)/ => '<%= config[:shortname] %>',
         | 
| 107 | 
            +
                default                 => '<%= config[:shortname] %>'
         | 
| 108 | 
            +
              }
         | 
| 109 | 
            +
              $hasstatus = $::operatingsystem ? {
         | 
| 110 | 
            +
                /(?i-mx:ubuntu|debian)/        => false,
         | 
| 111 | 
            +
                /(?i-mx:centos|fedora|redhat)/ => true,
         | 
| 112 | 
            +
                default => true,
         | 
| 113 | 
            +
              }
         | 
| 114 | 
            +
              $hasrestart = $::operatingsystem ? {
         | 
| 115 | 
            +
                default => true,
         | 
| 116 | 
            +
              }
         | 
| 110 117 |  | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
                 | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
                 | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 119 | 
            -
                 | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 122 | 
            -
                 | 
| 123 | 
            -
             | 
| 118 | 
            +
              # Configuration directory & file
         | 
| 119 | 
            +
              $configdir = $::operatingsystem ? {
         | 
| 120 | 
            +
                default => "/etc/<%= config[:shortname] %>",
         | 
| 121 | 
            +
              }
         | 
| 122 | 
            +
              $configdir_mode = $::operatingsystem ? {
         | 
| 123 | 
            +
                default => '0755',
         | 
| 124 | 
            +
              }
         | 
| 125 | 
            +
              $configdir_owner = $::operatingsystem ? {
         | 
| 126 | 
            +
                default => 'root',
         | 
| 127 | 
            +
              }
         | 
| 128 | 
            +
              $configdir_group = $::operatingsystem ? {
         | 
| 129 | 
            +
                default => 'root',
         | 
| 130 | 
            +
              }
         | 
| 124 131 |  | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
                 | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
                 | 
| 136 | 
            -
             | 
| 137 | 
            -
                }
         | 
| 138 | 
            -
                $configfile_group = $::operatingsystem ? {
         | 
| 139 | 
            -
                    default => 'root',
         | 
| 140 | 
            -
                }
         | 
| 132 | 
            +
              $configfile = $::operatingsystem ? {
         | 
| 133 | 
            +
                default => '/etc/<%= config[:shortname] %>.conf',
         | 
| 134 | 
            +
              }
         | 
| 135 | 
            +
              $configfile_mode = $::operatingsystem ? {
         | 
| 136 | 
            +
                default => '0600',
         | 
| 137 | 
            +
              }
         | 
| 138 | 
            +
              $configfile_owner = $::operatingsystem ? {
         | 
| 139 | 
            +
                default => 'root',
         | 
| 140 | 
            +
              }
         | 
| 141 | 
            +
              $configfile_group = $::operatingsystem ? {
         | 
| 142 | 
            +
                default => 'root',
         | 
| 143 | 
            +
              }
         | 
| 141 144 |  | 
| 145 | 
            +
              $default_sysconfig = $::operatingsystem ? {
         | 
| 146 | 
            +
                /(?i-mx:ubuntu|debian)/ => '/etc/default/<%= config[:shortname] %>',
         | 
| 147 | 
            +
                default                 => '/etc/sysconfig/<%= config[:shortname] %>'
         | 
| 148 | 
            +
              }
         | 
| 142 149 |  | 
| 143 150 | 
             
            }
         |