Best practices for sensu-puppet and plugins

Hi,

Given that a lot of the plugins that come with sensu require the installation of gems, what are the best practices for having them installed with puppet?

I was thinking that maybe you could force puppet to install them in the embedded ruby environment, so you don't end up "polluting" the debian system where it runs. Anybody has any recommendation/best practices advice?

Thanks.

Yes, I’m careful to always use the embedded ruby for plug-ins, and thus install any needed gems using the embedded gem command.

Ugly, but effective:

 $xml_simple_gem = "xml-simple-1.1.3.gem"

  file { "/var/tmp/${xml_simple_gem}":
    source => "puppet:///modules/profile/gems/${xml_simple_gem}",
    ensure => present,
    owner => 'root',
    group => 'root',

    mode => '0644',
  }
  exec { 'sensu-gem-install':
    require => [File["/var/tmp/${xml_simple_gem}"],Class['::sensu']],
    command => "/opt/sensu/embedded/bin/gem install /var/tmp/${xml_simple_gem}",

    unless => '/opt/sensu/embedded/bin/gem list xml-simple -i',
  }

Mojo

···

On Tue, Jun 10, 2014 at 10:00 AM, Jesús Roncero golan@notreally.org wrote:

Hi,

Given that a lot of the plugins that come with sensu require the installation of gems, what are the best practices for having them installed with puppet?

I was thinking that maybe you could force puppet to install them in the embedded ruby environment, so you don’t end up “polluting” the debian system where it runs. Anybody has any recommendation/best practices advice?

Thanks.

Hi,

Yes, I'm careful to always use the embedded ruby for plug-ins, and thus
install any needed gems using the embedded gem command.

Ugly, but effective:

Umm, yes, but interesting :slight_smile:

I guess that there's no way to tell it to use the gem provider but
indicating it's the embedded ruby...

I'll give it a try though. Thanks!

J.

···

On 10/06/2014 19:24, Mojo wrote:

> $xml_simple_gem = "xml-simple-1.1.3.gem"

  file { "/var/tmp/${xml_simple_gem}":
    source => "puppet:///modules/profile/gems/${xml_simple_gem}",
    ensure => present,
    owner => 'root',
    group => 'root',

    mode => '0644',
  }
  exec { 'sensu-gem-install':
    require => [File["/var/tmp/${xml_simple_gem}"],Class['::sensu']],
    command => "/opt/sensu/embedded/bin/gem install /var/tmp/${xml_simple_gem}",

    unless => '/opt/sensu/embedded/bin/gem list xml-simple -i',
  }|

Mojo

On Tue, Jun 10, 2014 at 10:00 AM, Jesús Roncero <golan@notreally.org > <mailto:golan@notreally.org>> wrote:

    Hi,

    Given that a lot of the plugins that come with sensu require the
    installation of gems, what are the best practices for having them
    installed with puppet?

    I was thinking that maybe you could force puppet to install them in
    the embedded ruby environment, so you don't end up "polluting" the
    debian system where it runs. Anybody has any recommendation/best
    practices advice?

    Thanks.

I used to use fpm to package up sensu ruby gems inside the embedded
environment in combination with EMBEDDED_RUBY=true:

fpm -s gem -t deb --gem-gem /opt/sensu/embedded/bin/gem
--gem-package-name-prefix=sensu-rubygem mail
(something like that. Maybe frob the deps, it can get messy if you
need lots of other dependent gems)

And then make puppet install the system package in order to not
pollute. (package { 'sensu-rubygem-mail': ensure => latest })

But then I gave up for some reason and decided to just use the system
ruby +gems instead. (easier to troubleshoot and maintain the gem
environment, mostly)

···

On Tue, Jun 10, 2014 at 2:59 PM, Jesus Roncero <golan@notreally.org> wrote:

Hi,

On 10/06/2014 19:24, Mojo wrote:

Yes, I'm careful to always use the embedded ruby for plug-ins, and thus
install any needed gems using the embedded gem command.

Ugly, but effective:

Umm, yes, but interesting :slight_smile:

I guess that there's no way to tell it to use the gem provider but
indicating it's the embedded ruby...

I'll give it a try though. Thanks!

J.

> $xml_simple_gem = "xml-simple-1.1.3.gem"

  file { "/var/tmp/${xml_simple_gem}":
    source => "puppet:///modules/profile/gems/${xml_simple_gem}",
    ensure => present,
    owner => 'root',
    group => 'root',

    mode => '0644',
  }
  exec { 'sensu-gem-install':
    require => [File["/var/tmp/${xml_simple_gem}"],Class['::sensu']],
    command => "/opt/sensu/embedded/bin/gem install /var/tmp/${xml_simple_gem}",

    unless => '/opt/sensu/embedded/bin/gem list xml-simple -i',
  }|

Mojo

On Tue, Jun 10, 2014 at 10:00 AM, Jesús Roncero <golan@notreally.org >> <mailto:golan@notreally.org>> wrote:

    Hi,

    Given that a lot of the plugins that come with sensu require the
    installation of gems, what are the best practices for having them
    installed with puppet?

    I was thinking that maybe you could force puppet to install them in
    the embedded ruby environment, so you don't end up "polluting" the
    debian system where it runs. Anybody has any recommendation/best
    practices advice?

    Thanks.

Hi,

I used to use fpm to package up sensu ruby gems inside the embedded
environment in combination with EMBEDDED_RUBY=true:

fpm -s gem -t deb --gem-gem /opt/sensu/embedded/bin/gem
--gem-package-name-prefix=sensu-rubygem mail
(something like that. Maybe frob the deps, it can get messy if you
need lots of other dependent gems)

And then make puppet install the system package in order to not
pollute. (package { 'sensu-rubygem-mail': ensure => latest })

But then I gave up for some reason and decided to just use the system
ruby +gems instead. (easier to troubleshoot and maintain the gem
environment, mostly)

The thing is that this approach is not going to go well where I work, as we try to keep things in packages as much as possible (better to manage with puppet and with other system tools).

Is that what people are mostly doing with sensu? Using the system ruby and then installing gems as you go? (as in, is that the recommended approach?)

Thanks.

···

On 11/06/14 05:05, Kyle Anderson wrote:

On Tue, Jun 10, 2014 at 2:59 PM, Jesus Roncero <golan@notreally.org> wrote:

Hi,

On 10/06/2014 19:24, Mojo wrote:

Yes, I'm careful to always use the embedded ruby for plug-ins, and thus
install any needed gems using the embedded gem command.

Ugly, but effective:

Umm, yes, but interesting :slight_smile:

I guess that there's no way to tell it to use the gem provider but
indicating it's the embedded ruby...

I'll give it a try though. Thanks!

J.

> $xml_simple_gem = "xml-simple-1.1.3.gem"

   file { "/var/tmp/${xml_simple_gem}":
     source => "puppet:///modules/profile/gems/${xml_simple_gem}",
     ensure => present,
     owner => 'root',
     group => 'root',

     mode => '0644',
   }
   exec { 'sensu-gem-install':
     require => [File["/var/tmp/${xml_simple_gem}"],Class['::sensu']],
     command => "/opt/sensu/embedded/bin/gem install /var/tmp/${xml_simple_gem}",

     unless => '/opt/sensu/embedded/bin/gem list xml-simple -i',
   }|

Mojo

On Tue, Jun 10, 2014 at 10:00 AM, Jesús Roncero <golan@notreally.org >>> <mailto:golan@notreally.org>> wrote:

     Hi,

     Given that a lot of the plugins that come with sensu require the
     installation of gems, what are the best practices for having them
     installed with puppet?

     I was thinking that maybe you could force puppet to install them in
     the embedded ruby environment, so you don't end up "polluting" the
     debian system where it runs. Anybody has any recommendation/best
     practices advice?

     Thanks.