# Best practices for sensu-puppet and plugins

**URL:** <https://discourse.sensu.io/t/best-practices-for-sensu-puppet-and-plugins/206>\
**Category:** Sensu Classic (EOL)\
**Created:** [June 10, 2014, 5:00pm UTC](https://discourse.sensu.io/t/best-practices-for-sensu-puppet-and-plugins/206 "2014-06-10T17:00:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesus\_Roncero](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jesus\_Roncero](https://discourse.sensu.io/u/Jesus_Roncero)\
**Post date:** [June 10, 2014, 5:00pm UTC](https://discourse.sensu.io/t/best-practices-for-sensu-puppet-and-plugins/206/1 "2014-06-10T17:00:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mojo](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@Mojo](https://discourse.sensu.io/u/Mojo)\
**Post date:** [June 10, 2014, 6:24pm UTC](https://discourse.sensu.io/t/best-practices-for-sensu-puppet-and-plugins/206/2 "2014-06-10T18:24:46Z")

</div>

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:

```auto
 $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.

---

<div class="post-metadata">

**Author:** ![Jesus\_Roncero](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jesus\_Roncero](https://discourse.sensu.io/u/Jesus_Roncero)\
**Post date:** [June 10, 2014, 9:59pm UTC](https://discourse.sensu.io/t/best-practices-for-sensu-puppet-and-plugins/206/3 "2014-06-10T21:59:03Z")

</div>

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 🙂

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"
> > 
> > &nbsp;&nbsp;file { "/var/tmp/${xml\_simple\_gem}":  
> > &nbsp;&nbsp;&nbsp;&nbsp;source =\> "puppet:///modules/profile/gems/${xml\_simple\_gem}",  
> > &nbsp;&nbsp;&nbsp;&nbsp;ensure =\> present,  
> > &nbsp;&nbsp;&nbsp;&nbsp;owner =\> 'root',  
> > &nbsp;&nbsp;&nbsp;&nbsp;group =\> 'root',
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;mode =\> '0644',  
> > &nbsp;&nbsp;}  
> > &nbsp;&nbsp;exec { 'sensu-gem-install':  
> > &nbsp;&nbsp;&nbsp;&nbsp;require =\> [File["/var/tmp/${xml\_simple\_gem}"],Class['::sensu']],  
> > &nbsp;&nbsp;&nbsp;&nbsp;command =\> "/opt/sensu/embedded/bin/gem install /var/tmp/${xml\_simple\_gem}",
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;unless =\> '/opt/sensu/embedded/bin/gem list xml-simple -i',  
> > &nbsp;&nbsp;}|
> > 
> > Mojo
> > 
> > On Tue, Jun 10, 2014 at 10:00 AM, Jesús Roncero \<golan@notreally.org \> \<mailto:golan@notreally.org\>\> wrote:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;Hi,
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;Given that a lot of the plugins that come with sensu require the  
> > &nbsp;&nbsp;&nbsp;&nbsp;installation of gems, what are the best practices for having them  
> > &nbsp;&nbsp;&nbsp;&nbsp;installed with puppet?
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;I was thinking that maybe you could force puppet to install them in  
> > &nbsp;&nbsp;&nbsp;&nbsp;the embedded ruby environment, so you don't end up "polluting" the  
> > &nbsp;&nbsp;&nbsp;&nbsp;debian system where it runs. Anybody has any recommendation/best  
> > &nbsp;&nbsp;&nbsp;&nbsp;practices advice?
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;Thanks.

---

<div class="post-metadata">

**Author:** ![Kyle\_Anderson](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@Kyle\_Anderson](https://discourse.sensu.io/u/Kyle_Anderson)\
**Post date:** [June 11, 2014, 4:05am UTC](https://discourse.sensu.io/t/best-practices-for-sensu-puppet-and-plugins/206/4 "2014-06-11T04:05:46Z")

</div>

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 🙂
> > 
> > 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"
> > > 
> > > &nbsp;&nbsp;file { "/var/tmp/${xml\_simple\_gem}":  
> > > &nbsp;&nbsp;&nbsp;&nbsp;source =\> "puppet:///modules/profile/gems/${xml\_simple\_gem}",  
> > > &nbsp;&nbsp;&nbsp;&nbsp;ensure =\> present,  
> > > &nbsp;&nbsp;&nbsp;&nbsp;owner =\> 'root',  
> > > &nbsp;&nbsp;&nbsp;&nbsp;group =\> 'root',
> > > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;mode =\> '0644',  
> > > &nbsp;&nbsp;}  
> > > &nbsp;&nbsp;exec { 'sensu-gem-install':  
> > > &nbsp;&nbsp;&nbsp;&nbsp;require =\> [File["/var/tmp/${xml\_simple\_gem}"],Class['::sensu']],  
> > > &nbsp;&nbsp;&nbsp;&nbsp;command =\> "/opt/sensu/embedded/bin/gem install /var/tmp/${xml\_simple\_gem}",
> > > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;unless =\> '/opt/sensu/embedded/bin/gem list xml-simple -i',  
> > > &nbsp;&nbsp;}|
> > > 
> > > Mojo
> > > 
> > > On Tue, Jun 10, 2014 at 10:00 AM, Jesús Roncero \<golan@notreally.org \>\> \<mailto:golan@notreally.org\>\> wrote:
> > > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;Hi,
> > > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;Given that a lot of the plugins that come with sensu require the  
> > > &nbsp;&nbsp;&nbsp;&nbsp;installation of gems, what are the best practices for having them  
> > > &nbsp;&nbsp;&nbsp;&nbsp;installed with puppet?
> > > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;I was thinking that maybe you could force puppet to install them in  
> > > &nbsp;&nbsp;&nbsp;&nbsp;the embedded ruby environment, so you don't end up "polluting" the  
> > > &nbsp;&nbsp;&nbsp;&nbsp;debian system where it runs. Anybody has any recommendation/best  
> > > &nbsp;&nbsp;&nbsp;&nbsp;practices advice?
> > > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;Thanks.

---

<div class="post-metadata">

**Author:** ![Jesus\_Roncero](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jesus\_Roncero](https://discourse.sensu.io/u/Jesus_Roncero)\
**Post date:** [June 11, 2014, 8:50am UTC](https://discourse.sensu.io/t/best-practices-for-sensu-puppet-and-plugins/206/5 "2014-06-11T08:50:41Z")

</div>

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 🙂
> > > 
> > > 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"
> > > > 
> > > > &nbsp;&nbsp;&nbsp;file { "/var/tmp/${xml\_simple\_gem}":  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;source =\> "puppet:///modules/profile/gems/${xml\_simple\_gem}",  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ensure =\> present,  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;owner =\> 'root',  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group =\> 'root',
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mode =\> '0644',  
> > > > &nbsp;&nbsp;&nbsp;}  
> > > > &nbsp;&nbsp;&nbsp;exec { 'sensu-gem-install':  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require =\> [File["/var/tmp/${xml\_simple\_gem}"],Class['::sensu']],  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command =\> "/opt/sensu/embedded/bin/gem install /var/tmp/${xml\_simple\_gem}",
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unless =\> '/opt/sensu/embedded/bin/gem list xml-simple -i',  
> > > > &nbsp;&nbsp;&nbsp;}|
> > > > 
> > > > Mojo
> > > > 
> > > > On Tue, Jun 10, 2014 at 10:00 AM, Jesús Roncero \<golan@notreally.org \>\>\> \<mailto:golan@notreally.org\>\> wrote:
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hi,
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Given that a lot of the plugins that come with sensu require the  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;installation of gems, what are the best practices for having them  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;installed with puppet?
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I was thinking that maybe you could force puppet to install them in  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the embedded ruby environment, so you don't end up "polluting" the  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;debian system where it runs. Anybody has any recommendation/best  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;practices advice?
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thanks.
