# Bash -\> chef

**URL:** <https://discourse.chef.io/t/bash-chef/3003>\
**Category:** Chef Infra (archive)\
**Created:** [August 10, 2012, 12:45am UTC](https://discourse.chef.io/t/bash-chef/3003 "2012-08-10T00:45:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward\_Morbius](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/edward_morbius/32/658_2.png) [@Edward\_Morbius](https://discourse.chef.io/u/Edward_Morbius)\
**Post date:** [August 10, 2012, 12:45am UTC](https://discourse.chef.io/t/bash-chef/3003/1 "2012-08-10T00:45:43Z")

</div>

I’ve been trying to wrap my head around chef and translating what  
would be a trivial bash script into the chef equivalent.

The goal is to include NewRelic’s host server (not application)  
monitoring on an Ubuntu box.

The bash process:

```
# Grab New Relic's apt sources.list fragment and tuck it away in

```

/etc/apt/sources.list.d  
wget -O /etc/apt/sources.list.d/newrelic.list  
[http://download.newrelic.com/debian/newrelic.list](http://download.newrelic.com/debian/newrelic.list)  
# Get their signing key (value previously ascertained)  
apt-key adv --keyserver hkp://subkeys.pgp.net --recv-keys 548C16BF  
# Run apt-get update and install package  
apt-get update  
apt-get install newrelic-sysmond  
# Set your license key (presumably stuffed in an encrypted data bag)  
nrsysmond-config --set license\_key=\<% key\_ID %\>  
# Launch the daemon  
/etc/init.d/newrelic-sysmond start

The easiest JGID method would be to write a ruby wrapper around the  
bash. For parts of this I find chef methods.

There’s an “apt” cookbook which can do some things, including adding a  
sources.list line, but apparently not downloading a sources.list.d/  
fragment from a known URL. Am I missing something?

The apt cookbook provides for getting the signing key:

```
apt_repository "newrelic-servermon" do
    keyserver "keyserver.pgp.edu"
    key "548C16BF"
end

```

Running the config step looks like another shell wrapper.

The service resource should be able to start the daemon:

```
service "newrelic-servermon" do
    supports :status -> true, :restart => true, :reload => true
    action [:enable, :start]
end

```

A nice “plus” feature would be an easy way to add, say, "monit"  
monitoring and possibly Nagios configuration for any given service,  
rather than managing these separately in a Nagios recipe.

TIA.

–  
Dr. Ed Morbius  
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator  
Krell Power Systems Unlimited

---

<div class="post-metadata">

**Author:** ![Alan\_Harper](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/alan_harper/32/596_2.png) [@Alan\_Harper](https://discourse.chef.io/u/Alan_Harper)\
**Post date:** [August 10, 2012, 12:52am UTC](https://discourse.chef.io/t/bash-chef/3003/2 "2012-08-10T00:52:09Z")

</div>

Have a look at the new relic cookbook at [https://github.com/heavywater/chef-newrelic](https://github.com/heavywater/chef-newrelic)

On 10/08/2012, at 10:45 AM, Edward Morbius [dredmorbius@gmail.com](mailto:dredmorbius@gmail.com) wrote:

> I've been trying to wrap my head around chef and translating what  
> would be a trivial bash script into the chef equivalent.
> 
> The goal is to include NewRelic's host server (not application)  
> monitoring on an Ubuntu box.
> 
> The bash process:
> 
> # Grab New Relic's apt sources.list fragment and tuck it away in
> 
> /etc/apt/sources.list.d  
> wget -O /etc/apt/sources.list.d/newrelic.list  
> [http://download.newrelic.com/debian/newrelic.list](http://download.newrelic.com/debian/newrelic.list)
> 
> # Get their signing key (value previously ascertained)
> 
> apt-key adv --keyserver hkp://subkeys.pgp.net --recv-keys 548C16BF
> 
> # Run apt-get update and install package
> 
> apt-get update  
> apt-get install newrelic-sysmond
> 
> # Set your license key (presumably stuffed in an encrypted data bag)
> 
> nrsysmond-config --set license\_key=\<% key\_ID %\>
> 
> # Launch the daemon
> 
> /etc/init.d/newrelic-sysmond start
> 
> The easiest JGID method would be to write a ruby wrapper around the  
> bash. For parts of this I find chef methods.
> 
> There's an "apt" cookbook which can do some things, including adding a  
> sources.list line, but apparently not downloading a sources.list.d/  
> fragment from a known URL. Am I missing something?
> 
> The apt cookbook provides for getting the signing key:
> 
> apt\_repository "newrelic-servermon" do  
> keyserver "keyserver.pgp.edu"  
> key "548C16BF"  
> end
> 
> Running the config step looks like another shell wrapper.
> 
> The service resource should be able to start the daemon:
> 
> service "newrelic-servermon" do  
> supports :status -\> true, :restart =\> true, :reload =\> true  
> action [:enable, :start]  
> end
> 
> A nice "plus" feature would be an easy way to add, say, "monit"  
> monitoring and possibly Nagios configuration for any given service,  
> rather than managing these separately in a Nagios recipe.
> 
> TIA.
> 
> --  
> Dr. Ed Morbius  
> Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator  
> Krell Power Systems Unlimited

---

<div class="post-metadata">

**Author:** ![Edward\_Morbius](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/edward_morbius/32/658_2.png) [@Edward\_Morbius](https://discourse.chef.io/u/Edward_Morbius)\
**Post date:** [August 10, 2012, 1:37am UTC](https://discourse.chef.io/t/bash-chef/3003/3 "2012-08-10T01:37:35Z")

</div>

Thanks. Giving that a shot (a few twists on the recipe shown, so I'm  
not using it directly).

And it seems to answer my first question: there's no way of handling  
an apt archive sourced from a URL directly.

On Thu, Aug 9, 2012 at 5:52 PM, Alan Harper [alan@aussiegeek.net](mailto:alan@aussiegeek.net) wrote:

> Have a look at the new relic cookbook at  
> [GitHub - heavywater/chef-newrelic: "Installs/Configures newrelic"](https://github.com/heavywater/chef-newrelic)
> 
> On 10/08/2012, at 10:45 AM, Edward Morbius [dredmorbius@gmail.com](mailto:dredmorbius@gmail.com) wrote:
> 
> I've been trying to wrap my head around chef and translating what  
> would be a trivial bash script into the chef equivalent.
> 
> The goal is to include NewRelic's host server (not application)  
> monitoring on an Ubuntu box.
> 
> The bash process:
> 
> # Grab New Relic's apt sources.list fragment and tuck it away in
> 
> /etc/apt/sources.list.d  
> wget -O /etc/apt/sources.list.d/newrelic.list  
> [http://download.newrelic.com/debian/newrelic.list](http://download.newrelic.com/debian/newrelic.list)
> 
> # Get their signing key (value previously ascertained)
> 
> apt-key adv --keyserver hkp://subkeys.pgp.net --recv-keys 548C16BF
> 
> # Run apt-get update and install package
> 
> apt-get update  
> apt-get install newrelic-sysmond
> 
> # Set your license key (presumably stuffed in an encrypted data bag)
> 
> nrsysmond-config --set license\_key=\<% key\_ID %\>
> 
> # Launch the daemon
> 
> /etc/init.d/newrelic-sysmond start
> 
> The easiest JGID method would be to write a ruby wrapper around the  
> bash. For parts of this I find chef methods.
> 
> There's an "apt" cookbook which can do some things, including adding a  
> sources.list line, but apparently not downloading a sources.list.d/  
> fragment from a known URL. Am I missing something?
> 
> The apt cookbook provides for getting the signing key:
> 
> apt\_repository "newrelic-servermon" do  
> keyserver "keyserver.pgp.edu"  
> key "548C16BF"  
> end
> 
> Running the config step looks like another shell wrapper.
> 
> The service resource should be able to start the daemon:
> 
> service "newrelic-servermon" do  
> supports :status -\> true, :restart =\> true, :reload =\> true  
> action [:enable, :start]  
> end
> 
> A nice "plus" feature would be an easy way to add, say, "monit"  
> monitoring and possibly Nagios configuration for any given service,  
> rather than managing these separately in a Nagios recipe.
> 
> TIA.
> 
> --  
> Dr. Ed Morbius  
> Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator  
> Krell Power Systems Unlimited

--  
Dr. Ed Morbius  
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator  
Krell Power Systems Unlimited

---

<div class="post-metadata">

**Author:** ![Mike](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mike/32/18_2.png) [@Mike](https://discourse.chef.io/u/Mike)\
**Post date:** [August 10, 2012, 1:46am UTC](https://discourse.chef.io/t/bash-chef/3003/4 "2012-08-10T01:46:59Z")

</div>

> And it seems to answer my first question: there's no way of handling  
> an apt archive sourced from a URL directly.  
> I don't think I understand this question.

If the .list file is all you want, then you may use a remote\_file  
resource for that.

The apt cookbook provides a LWRP that could be sued as such:

apt\_repository "newrelic" do  
uri "[http://apt.newrelic.com/debian/](http://apt.newrelic.com/debian/)"  
distribution "newrelic"  
components ["non-free"]  
keyserver "keyserver.pgp.edu"  
key "548C16BF"  
end

(untested, but syntax should be close)

This should output a .list file containing the details that the one  
you've linked to, as well as handle importing the gpg key.

HTH.  
-M

On Thu, Aug 9, 2012 at 9:37 PM, Edward Morbius [dredmorbius@gmail.com](mailto:dredmorbius@gmail.com) wrote:

> Thanks. Giving that a shot (a few twists on the recipe shown, so I'm  
> not using it directly).
> 
> And it seems to answer my first question: there's no way of handling  
> an apt archive sourced from a URL directly.
> 
> On Thu, Aug 9, 2012 at 5:52 PM, Alan Harper [alan@aussiegeek.net](mailto:alan@aussiegeek.net) wrote:
> 
> > Have a look at the new relic cookbook at  
> > [GitHub - heavywater/chef-newrelic: "Installs/Configures newrelic"](https://github.com/heavywater/chef-newrelic)
> > 
> > On 10/08/2012, at 10:45 AM, Edward Morbius [dredmorbius@gmail.com](mailto:dredmorbius@gmail.com) wrote:
> > 
> > I've been trying to wrap my head around chef and translating what  
> > would be a trivial bash script into the chef equivalent.
> > 
> > The goal is to include NewRelic's host server (not application)  
> > monitoring on an Ubuntu box.
> > 
> > The bash process:
> > 
> > # Grab New Relic's apt sources.list fragment and tuck it away in
> > 
> > /etc/apt/sources.list.d  
> > wget -O /etc/apt/sources.list.d/newrelic.list  
> > [http://download.newrelic.com/debian/newrelic.list](http://download.newrelic.com/debian/newrelic.list)
> > 
> > # Get their signing key (value previously ascertained)
> > 
> > apt-key adv --keyserver hkp://subkeys.pgp.net --recv-keys 548C16BF
> > 
> > # Run apt-get update and install package
> > 
> > apt-get update  
> > apt-get install newrelic-sysmond
> > 
> > # Set your license key (presumably stuffed in an encrypted data bag)
> > 
> > nrsysmond-config --set license\_key=\<% key\_ID %\>
> > 
> > # Launch the daemon
> > 
> > /etc/init.d/newrelic-sysmond start
> > 
> > The easiest JGID method would be to write a ruby wrapper around the  
> > bash. For parts of this I find chef methods.
> > 
> > There's an "apt" cookbook which can do some things, including adding a  
> > sources.list line, but apparently not downloading a sources.list.d/  
> > fragment from a known URL. Am I missing something?
> > 
> > The apt cookbook provides for getting the signing key:
> > 
> > apt\_repository "newrelic-servermon" do  
> > keyserver "keyserver.pgp.edu"  
> > key "548C16BF"  
> > end
> > 
> > Running the config step looks like another shell wrapper.
> > 
> > The service resource should be able to start the daemon:
> > 
> > service "newrelic-servermon" do  
> > supports :status -\> true, :restart =\> true, :reload =\> true  
> > action [:enable, :start]  
> > end
> > 
> > A nice "plus" feature would be an easy way to add, say, "monit"  
> > monitoring and possibly Nagios configuration for any given service,  
> > rather than managing these separately in a Nagios recipe.
> > 
> > TIA.
> > 
> > --  
> > Dr. Ed Morbius  
> > Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator  
> > Krell Power Systems Unlimited
> 
> --  
> Dr. Ed Morbius  
> Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator  
> Krell Power Systems Unlimited

---

<div class="post-metadata">

**Author:** ![Edward\_Morbius](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/edward_morbius/32/658_2.png) [@Edward\_Morbius](https://discourse.chef.io/u/Edward_Morbius)\
**Post date:** [August 10, 2012, 6:49pm UTC](https://discourse.chef.io/t/bash-chef/3003/5 "2012-08-10T18:49:54Z")

</div>

Yeah, that's what I'm working with.

On Thu, Aug 9, 2012 at 6:46 PM, Mike [miketheman@gmail.com](mailto:miketheman@gmail.com) wrote:

> > And it seems to answer my first question: there's no way of handling  
> > an apt archive sourced from a URL directly.  
> > I don't think I understand this question.
> 
> If the .list file is all you want, then you may use a remote\_file  
> resource for that.
> 
> The apt cookbook provides a LWRP that could be sued as such:
> 
> apt\_repository "newrelic" do  
> uri "[http://apt.newrelic.com/debian/](http://apt.newrelic.com/debian/)"  
> distribution "newrelic"  
> components ["non-free"]  
> keyserver "keyserver.pgp.edu"  
> key "548C16BF"  
> end
> 
> (untested, but syntax should be close)
> 
> This should output a .list file containing the details that the one  
> you've linked to, as well as handle importing the gpg key.
> 
> HTH.  
> -M
> 
> On Thu, Aug 9, 2012 at 9:37 PM, Edward Morbius [dredmorbius@gmail.com](mailto:dredmorbius@gmail.com) wrote:
> 
> > Thanks. Giving that a shot (a few twists on the recipe shown, so I'm  
> > not using it directly).
> > 
> > And it seems to answer my first question: there's no way of handling  
> > an apt archive sourced from a URL directly.
> > 
> > On Thu, Aug 9, 2012 at 5:52 PM, Alan Harper [alan@aussiegeek.net](mailto:alan@aussiegeek.net) wrote:
> > 
> > > Have a look at the new relic cookbook at  
> > > [GitHub - heavywater/chef-newrelic: "Installs/Configures newrelic"](https://github.com/heavywater/chef-newrelic)
> > > 
> > > On 10/08/2012, at 10:45 AM, Edward Morbius [dredmorbius@gmail.com](mailto:dredmorbius@gmail.com) wrote:
> > > 
> > > I've been trying to wrap my head around chef and translating what  
> > > would be a trivial bash script into the chef equivalent.
> > > 
> > > The goal is to include NewRelic's host server (not application)  
> > > monitoring on an Ubuntu box.
> > > 
> > > The bash process:
> > > 
> > > # Grab New Relic's apt sources.list fragment and tuck it away in
> > > 
> > > /etc/apt/sources.list.d  
> > > wget -O /etc/apt/sources.list.d/newrelic.list  
> > > [http://download.newrelic.com/debian/newrelic.list](http://download.newrelic.com/debian/newrelic.list)
> > > 
> > > # Get their signing key (value previously ascertained)
> > > 
> > > apt-key adv --keyserver hkp://subkeys.pgp.net --recv-keys 548C16BF
> > > 
> > > # Run apt-get update and install package
> > > 
> > > apt-get update  
> > > apt-get install newrelic-sysmond
> > > 
> > > # Set your license key (presumably stuffed in an encrypted data bag)
> > > 
> > > nrsysmond-config --set license\_key=\<% key\_ID %\>
> > > 
> > > # Launch the daemon
> > > 
> > > /etc/init.d/newrelic-sysmond start
> > > 
> > > The easiest JGID method would be to write a ruby wrapper around the  
> > > bash. For parts of this I find chef methods.
> > > 
> > > There's an "apt" cookbook which can do some things, including adding a  
> > > sources.list line, but apparently not downloading a sources.list.d/  
> > > fragment from a known URL. Am I missing something?
> > > 
> > > The apt cookbook provides for getting the signing key:
> > > 
> > > apt\_repository "newrelic-servermon" do  
> > > keyserver "keyserver.pgp.edu"  
> > > key "548C16BF"  
> > > end
> > > 
> > > Running the config step looks like another shell wrapper.
> > > 
> > > The service resource should be able to start the daemon:
> > > 
> > > service "newrelic-servermon" do  
> > > supports :status -\> true, :restart =\> true, :reload =\> true  
> > > action [:enable, :start]  
> > > end
> > > 
> > > A nice "plus" feature would be an easy way to add, say, "monit"  
> > > monitoring and possibly Nagios configuration for any given service,  
> > > rather than managing these separately in a Nagios recipe.
> > > 
> > > TIA.
> > > 
> > > --  
> > > Dr. Ed Morbius  
> > > Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator  
> > > Krell Power Systems Unlimited
> > 
> > --  
> > Dr. Ed Morbius  
> > Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator  
> > Krell Power Systems Unlimited

--  
Dr. Ed Morbius  
Chief Scientist / Philologist / Robot Wrangler / Powerplant Operator  
Krell Power Systems Unlimited
