[Puppet Users] Dividing init.pp into components

David Jarosch
Thu, 16 Jan 2014 11:04:56 -0000

Hey guys,

I'm having some problems dividing my init.pp into components like
package.pp, config.pp and service.pp. Unfortunately I'm getting several
error's after running puppet-lint like:

ERROR: nrpe::package not in autoload module layout on line 1
ERROR: nrpe::service not in autoload module layout on line 1
ERROR: Syntax error (try running `puppet parser validate <file>`) on line
3
ERROR: nrpe::config not in autoload module layout on line 1

etc.

Here my code, maybe someone of you can give me a hint where to look at:

*init.pp*

### INSTALLS NRPE INCLUDING DEFINING SERVER AND SETTING UP PLUGINS ###
class nrpe {
  class { '::nrpe::package': } ->
  class { '::nrpe::config': }  ->
  class { '::nrpe::service': } ->
  Class['nrpe']
}

*package.pp*

class nrpe::package {
  package { 'nagios-nrpe-server':
    ensure      => 'latest',
    require     => Class['apt::update'],
  }

  ### INSTALL NRPE PLUGINS WITHOUT ADDITIONAL RECOMMENDED PACKAGES
  exec { 'nagios-nrpe-plugin':
    unless      => '/usr/bin/dpkg -l |grep nagios-nrpe-plugin',
    require     => Class['nrpe::package'],
    command     => '/usr/bin/apt-get install nagios-nrpe-plugin -y
--no-install-recommends';
  }

  ### INSTALL ICINGA PLUGINS WITHOUT ADDITIONAL RECOMMENDED PACKAGES
  exec { 'nagios-plugins':
    unless      => '/usr/bin/dpkg -l |grep nagios-plugins',
    require     => Class['nrpe::package'],
    command     => '/usr/bin/apt-get install nagios-plugins -y
--no-install-recommends';
  }
}

*config.pp*

class nrpe::config {
  file {
    '/etc/nagios/nrpe.cfg':
      source    => 'puppet:///modules/nrpe/nrpe.cfg',
      require   => Class['nrpe::package'],
      notify    => Class['nrpe::service'],
      mode      => '0644',
      owner     => 'nagios',
      group     => 'nagios';

    '/etc/init.d/nrpe':
      source    => 'puppet:///modules/nrpe/nrpe_init.d',
      require   => Class['nrpe::package'],
      notify    => Class['nrpe::service'],
      mode      => '0755',
      owner     => 'root',
      group     => 'root';

    '/etc/nagios/nrpe.d/nrpe_all.cfg':
      source    => 'puppet:///modules/nrpe/nrpe_all',
      require   => Class['nrpe::package'],
      notify    => Class['nrpe::service'],
      mode      => '0644',
      owner     => 'nagios',
      group     => 'nagios';

    '/usr/lib/nagios/plugins/check_linux_raid':
      source    => 'puppet:///modules/nrpe/plugins/check_linux_raid',
      require   => Class['nrpe::package'],
      notify    => Class['nrpe::service'],
      mode      => '0755',
      owner     => 'nagios',
      group     => 'nagios';

    '/usr/lib/nagios/plugins/check_md_raid':
      source    => 'puppet:///modules/nrpe/plugins/check_md_raid',
      require   => Class['nrpe::package'],
      notify    => Class['nrpe::service'],
      mode      => '0755',
      owner     => 'nagios',
      group     => 'nagios';
  }
}

*service.pp*

class nrpe::service {
  service { 'nrpe':
    ensure      => running,
    enable      => true,
    require     => Class['nrpe::config'],
  }
}


Folder structure on Puppetmaster:

/etc/puppet/git/modules/nrpe/manifests# tree -d /etc/puppet/git/modules/
/etc/puppet/git/modules/
├── nrpe
│   ├── files
│   │   ├── plugins
│   │   ├── rs0
│   │   ├── rs1
│   │   ├── rs2
│   │   ├── rs3
│   │   └── rs4
│   ├── manifests
│   │   └── Testing
│   ├── spec
│   └── tests

Cheers,
David

--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/e4f6d95e-7f97-4f95-9353-8fca507f7a70%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.