# Ohai Plugin Running External Commands

**URL:** <https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120>\
**Category:** Chef Infra (archive)\
**Created:** [December 3, 2014, 4:28pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120 "2014-12-03T16:28:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [December 3, 2014, 4:28pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120/1 "2014-12-03T16:28:13Z")

</div>

Has anyone got any examples of custom ohai plugins calling external shell  
commands in ruby and returning the result? Having trouble with it. Need to  
pull some EC2 tags into chef (via AWS CLI) and an ohai plugin seemed like  
the right idea.

Doug

---

<div class="post-metadata">

**Author:** ![Matt\_Ray\_GETCHEF](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/matt_ray_getchef/32/180_2.png) [@Matt\_Ray\_GETCHEF](https://discourse.chef.io/u/Matt_Ray_GETCHEF)\
**Post date:** [December 3, 2014, 4:35pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120/2 "2014-12-03T16:35:27Z")

</div>

Lots of examples in the lib/ohai/plugins/ directory for things called  
by Mixlib::ShellOut. Check this

> <https://github.com/chef/ohai/blob/main/lib/ohai/plugins/kernel.rb#L102>

Thanks,  
Matt Ray  
Director of Partner Integration :: Chef  
[matt@chef.io](mailto:matt@chef.io) :: 512.731.2218  
mattray :: GitHub :: IRC :: Twitter

On Wed, Dec 3, 2014 at 10:28 AM, Douglas Garstang  
[doug.garstang@gmail.com](mailto:doug.garstang@gmail.com) wrote:

> Has anyone got any examples of custom ohai plugins calling external shell  
> commands in ruby and returning the result? Having trouble with it. Need to  
> pull some EC2 tags into chef (via AWS CLI) and an ohai plugin seemed like  
> the right idea.
> 
> Doug

---

<div class="post-metadata">

**Author:** ![Jeremy\_Mauro](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@Jeremy\_Mauro](https://discourse.chef.io/u/Jeremy_Mauro)\
**Post date:** [December 3, 2014, 4:45pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120/3 "2014-12-03T16:45:21Z")

</div>

Here is one of our ohai :  
lspci = Mixlib::ShellOut.new(  
‘lspci -m’,  
\<% if node[‘platform\_family’] == ‘windows’ -%\>  
:cwd =\> “\<%= node[:pciutils][:path] %\>”,  
\<% end -%\>  
)  
lspci.run\_command  
stdout, stderr = [lspci.stdout, lspci.stderr]

From: Douglas Garstang [[mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)]  
Sent: mercredi 3 décembre 2014 17:28  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Ohai Plugin Running External Commands

Has anyone got any examples of custom ohai plugins calling external shell commands in ruby and returning the result? Having trouble with it. Need to pull some EC2 tags into chef (via AWS CLI) and an ohai plugin seemed like the right idea.  
Doug

---

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [December 3, 2014, 6:20pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120/4 "2014-12-03T18:20:04Z")

</div>

Thanks.

I was actually trying to get a list of ec2 instances having tags with  
specific values. I don't want to use chef search due to the requirement  
that all the nodes must have successfully completed a chef run first.

Douglas.

On Wed, Dec 3, 2014 at 8:45 AM, Jeremy Mauro [j.mauro@criteo.com](mailto:j.mauro@criteo.com) wrote:

> Here is one of our ohai :
> 
> lspci = Mixlib::ShellOut.new(
> 
> ```
> 'lspci -m',
> 
> ```
> 
> \<% if node['platform\_family'] == 'windows' -%\>
> 
> ```
> :cwd => "<%= node[:pciutils][:path] %>",
> 
> ```
> 
> \<% end -%\>
> 
> )
> 
> lspci.run\_command
> 
> stdout, stderr = [lspci.stdout, lspci.stderr]
> 
> _From:_ Douglas Garstang [[mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)]  
> _Sent:_ mercredi 3 décembre 2014 17:28  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Ohai Plugin Running External Commands
> 
> Has anyone got any examples of custom ohai plugins calling external shell  
> commands in ruby and returning the result? Having trouble with it. Need to  
> pull some EC2 tags into chef (via AWS CLI) and an ohai plugin seemed like  
> the right idea.
> 
> Doug

--  
Regards,

Douglas Garstang  
[http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
Cell: +1-805-340-5627

---

<div class="post-metadata">

**Author:** ![Dennis\_Lovely](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@Dennis\_Lovely](https://discourse.chef.io/u/Dennis_Lovely)\
**Post date:** [December 3, 2014, 6:31pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120/5 "2014-12-03T18:31:46Z")

</div>

You can search with AWS CLI:

ec2-describe-instances --filter "tag:YourTagName=YourRequestedValue"

Is this what you're looking for?

hth

-Dennis

On Wed, Dec 3, 2014 at 10:20 AM, Douglas Garstang [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
wrote:

> Thanks.
> 
> I was actually trying to get a list of ec2 instances having tags with  
> specific values. I don't want to use chef search due to the requirement  
> that all the nodes must have successfully completed a chef run first.
> 
> Douglas.
> 
> On Wed, Dec 3, 2014 at 8:45 AM, Jeremy Mauro [j.mauro@criteo.com](mailto:j.mauro@criteo.com) wrote:
> 
> > Here is one of our ohai :
> > 
> > lspci = Mixlib::ShellOut.new(
> > 
> > ```
> > 'lspci -m',
> > 
> > ```
> > 
> > \<% if node['platform\_family'] == 'windows' -%\>
> > 
> > ```
> > :cwd => "<%= node[:pciutils][:path] %>",
> > 
> > ```
> > 
> > \<% end -%\>
> > 
> > )
> > 
> > lspci.run\_command
> > 
> > stdout, stderr = [lspci.stdout, lspci.stderr]
> > 
> > _From:_ Douglas Garstang [[mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)]  
> > _Sent:_ mercredi 3 décembre 2014 17:28  
> > _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > _Subject:_ [chef] Ohai Plugin Running External Commands
> > 
> > Has anyone got any examples of custom ohai plugins calling external shell  
> > commands in ruby and returning the result? Having trouble with it. Need to  
> > pull some EC2 tags into chef (via AWS CLI) and an ohai plugin seemed like  
> > the right idea.
> > 
> > Doug
> 
> --  
> Regards,
> 
> Douglas Garstang  
> [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> Cell: +1-805-340-5627

---

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [December 3, 2014, 6:36pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120/6 "2014-12-03T18:36:23Z")

</div>

Dennis,

Of course. It's just translating that into something that ohai runs and  
returns as a dictionary that's tricky. The plugin also has to run the aws  
cli to get it's environment and role and feed that back into the  
describe-instances to get a list of matching instances. It seems like a  
rather clunky approach. I certainly don't want to run chef search due to  
the whole having-to-have-already run thing, which means the chef client has  
to then get run multiple times. Not scalable.

Douglas.

On Wed, Dec 3, 2014 at 10:31 AM, Dennis Lovely [dl@aegisco.com](mailto:dl@aegisco.com) wrote:

> You can search with AWS CLI:
> 
> ec2-describe-instances --filter "tag:YourTagName=YourRequestedValue"
> 
> Is this what you're looking for?
> 
> hth
> 
> -Dennis
> 
> On Wed, Dec 3, 2014 at 10:20 AM, Douglas Garstang \<[doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)
> 
> > wrote:
> 
> > Thanks.
> > 
> > I was actually trying to get a list of ec2 instances having tags with  
> > specific values. I don't want to use chef search due to the requirement  
> > that all the nodes must have successfully completed a chef run first.
> > 
> > Douglas.
> > 
> > On Wed, Dec 3, 2014 at 8:45 AM, Jeremy Mauro [j.mauro@criteo.com](mailto:j.mauro@criteo.com) wrote:
> > 
> > > Here is one of our ohai :
> > > 
> > > lspci = Mixlib::ShellOut.new(
> > > 
> > > ```
> > > 'lspci -m',
> > > 
> > > ```
> > > 
> > > \<% if node['platform\_family'] == 'windows' -%\>
> > > 
> > > ```
> > > :cwd => "<%= node[:pciutils][:path] %>",
> > > 
> > > ```
> > > 
> > > \<% end -%\>
> > > 
> > > )
> > > 
> > > lspci.run\_command
> > > 
> > > stdout, stderr = [lspci.stdout, lspci.stderr]
> > > 
> > > _From:_ Douglas Garstang [[mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)]  
> > > _Sent:_ mercredi 3 décembre 2014 17:28  
> > > _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > > _Subject:_ [chef] Ohai Plugin Running External Commands
> > > 
> > > Has anyone got any examples of custom ohai plugins calling external  
> > > shell commands in ruby and returning the result? Having trouble with it.  
> > > Need to pull some EC2 tags into chef (via AWS CLI) and an ohai plugin  
> > > seemed like the right idea.
> > > 
> > > Doug
> > 
> > --  
> > Regards,
> > 
> > Douglas Garstang  
> > [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> > Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> > Cell: +1-805-340-5627

--  
Regards,

Douglas Garstang  
[http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
Cell: +1-805-340-5627

---

<div class="post-metadata">

**Author:** ![dcondomitti](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dcondomitti/32/104_2.png) [@dcondomitti](https://discourse.chef.io/u/dcondomitti)\
**Post date:** [December 3, 2014, 7:24pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120/7 "2014-12-03T19:24:31Z")

</div>

I would recommend using the API directly instead of shelling out to aws-cli just to parse it back into a machine readable format. Fog[0] is a good place to start and supports multiple cloud providers if you end up going down that route. I don’t know for sure that it allows searching by instance tag (over listing all instances and filtering) but I would expect that it does.

Dan

[0] [GitHub - fog/fog: The Ruby cloud services library.](https://github.com/fog/fog)

On Wednesday, December 3, 2014 at 1:36 PM, Douglas Garstang wrote:

> Dennis,
> 
> Of course. It's just translating that into something that ohai runs and returns as a dictionary that's tricky. The plugin also has to run the aws cli to get it's environment and role and feed that back into the describe-instances to get a list of matching instances. It seems like a rather clunky approach. I certainly don't want to run chef search due to the whole having-to-have-already run thing, which means the chef client has to then get run multiple times. Not scalable.
> 
> Douglas.
> 
> On Wed, Dec 3, 2014 at 10:31 AM, Dennis Lovely \<[dl@aegisco.com](mailto:dl@aegisco.com) ([mailto:dl@aegisco.com](mailto:dl@aegisco.com))\> wrote:
> 
> > You can search with AWS CLI:  
> > ec2-describe-instances --filter "tag:YourTagName=YourRequestedValue"  
> > Is this what you're looking for?  
> > hth
> > 
> > -Dennis
> > 
> > On Wed, Dec 3, 2014 at 10:20 AM, Douglas Garstang \<[doug.garstang@gmail.com](mailto:doug.garstang@gmail.com) ([mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com))\> wrote:
> > 
> > > Thanks.
> > > 
> > > I was actually trying to get a list of ec2 instances having tags with specific values. I don't want to use chef search due to the requirement that all the nodes must have successfully completed a chef run first.
> > > 
> > > Douglas.
> > > 
> > > On Wed, Dec 3, 2014 at 8:45 AM, Jeremy Mauro \<[j.mauro@criteo.com](mailto:j.mauro@criteo.com) ([mailto:j.mauro@criteo.com](mailto:j.mauro@criteo.com))\> wrote:
> > > 
> > > > Here is one of our ohai :  
> > > > lspci = Mixlib::ShellOut.new(  
> > > > 'lspci -m',  
> > > > \<% if node['platform\_family'] == 'windows' -%\>  
> > > > :cwd =\> "\<%= node[:pciutils][:path] %\>",  
> > > > \<% end -%\>  
> > > > )  
> > > > lspci.run\_command  
> > > > stdout, stderr = [lspci.stdout, lspci.stderr]
> > > > 
> > > > From: Douglas Garstang [[mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)]  
> > > > Sent: mercredi 3 décembre 2014 17:28  
> > > > To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com) ([mailto:chef@lists.opscode.com](mailto:chef@lists.opscode.com))  
> > > > Subject: [chef] Ohai Plugin Running External Commands
> > > > 
> > > > Has anyone got any examples of custom ohai plugins calling external shell commands in ruby and returning the result? Having trouble with it. Need to pull some EC2 tags into chef (via AWS CLI) and an ohai plugin seemed like the right idea.
> > > > 
> > > > Doug
> > > 
> > > --  
> > > Regards,
> > > 
> > > Douglas Garstang  
> > > [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> > > Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com) ([mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com))  
> > > Cell: +1-805-340-5627 (tel:%2B1-805-340-5627)
> 
> --  
> Regards,
> 
> Douglas Garstang  
> [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com) ([mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com))  
> Cell: +1-805-340-5627

---

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [December 3, 2014, 7:59pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120/8 "2014-12-03T19:59:43Z")

</div>

Don't suppose you know if fog lets you perform AWS operations without an  
access key/secret access key when the instance belongs to an IAM profile?  
Can't find specific docs on this, and when I leave them out (which I can do  
with python boto), it just complains they are missing.

I'm also installing fog with "gem install fog –no-ri –no-rdoc" and have  
been waiting about 20 minutes for for "Parsing documentation for  
fog-1.25.0" to complete on an m3.large EC2 instance. ☹

Doug.

On Wed, Dec 3, 2014 at 11:24 AM, Daniel Condomitti [daniel@condomitti.com](mailto:daniel@condomitti.com)  
wrote:

> I would recommend using the API directly instead of shelling out to  
> aws-cli just to parse it back into a machine readable format. Fog[0] is a  
> good place to start and supports multiple cloud providers if you end up  
> going down that route. I don’t know for sure that it allows searching by  
> instance tag (over listing all instances and filtering) but I would expect  
> that it does.
> 
> Dan
> 
> [0] [GitHub - fog/fog: The Ruby cloud services library.](https://github.com/fog/fog)
> 
> On Wednesday, December 3, 2014 at 1:36 PM, Douglas Garstang wrote:
> 
> Dennis,
> 
> Of course. It's just translating that into something that ohai runs and  
> returns as a dictionary that's tricky. The plugin also has to run the aws  
> cli to get it's environment and role and feed that back into the  
> describe-instances to get a list of matching instances. It seems like a  
> rather clunky approach. I certainly don't want to run chef search due to  
> the whole having-to-have-already run thing, which means the chef client has  
> to then get run multiple times. Not scalable.
> 
> Douglas.
> 
> On Wed, Dec 3, 2014 at 10:31 AM, Dennis Lovely [dl@aegisco.com](mailto:dl@aegisco.com) wrote:
> 
> You can search with AWS CLI:
> 
> ec2-describe-instances --filter "tag:YourTagName=YourRequestedValue"
> 
> Is this what you're looking for?
> 
> hth
> 
> -Dennis
> 
> On Wed, Dec 3, 2014 at 10:20 AM, Douglas Garstang \<[doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)
> 
> > wrote:
> 
> Thanks.
> 
> I was actually trying to get a list of ec2 instances having tags with  
> specific values. I don't want to use chef search due to the requirement  
> that all the nodes must have successfully completed a chef run first.
> 
> Douglas.
> 
> On Wed, Dec 3, 2014 at 8:45 AM, Jeremy Mauro [j.mauro@criteo.com](mailto:j.mauro@criteo.com) wrote:
> 
> Here is one of our ohai :
> 
> lspci = Mixlib::ShellOut.new(
> 
> ```
> 'lspci -m',
> 
> ```
> 
> \<% if node['platform\_family'] == 'windows' -%\>
> 
> ```
> :cwd => "<%= node[:pciutils][:path] %>",
> 
> ```
> 
> \<% end -%\>
> 
> )
> 
> lspci.run\_command
> 
> stdout, stderr = [lspci.stdout, lspci.stderr]
> 
> _From:_ Douglas Garstang [[mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)]  
> _Sent:_ mercredi 3 décembre 2014 17:28  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Ohai Plugin Running External Commands
> 
> Has anyone got any examples of custom ohai plugins calling external shell  
> commands in ruby and returning the result? Having trouble with it. Need to  
> pull some EC2 tags into chef (via AWS CLI) and an ohai plugin seemed like  
> the right idea.
> 
> Doug
> 
> --  
> Regards,
> 
> Douglas Garstang  
> [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> Cell: +1-805-340-5627
> 
> --  
> Regards,
> 
> Douglas Garstang  
> [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> Cell: +1-805-340-5627

--  
Regards,

Douglas Garstang  
[http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
Cell: +1-805-340-5627

---

<div class="post-metadata">

**Author:** ![AJ\_Christensen2](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/aj_christensen2/32/42_2.png) [@AJ\_Christensen2](https://discourse.chef.io/u/AJ_Christensen2)\
**Post date:** [December 3, 2014, 8:05pm UTC](https://discourse.chef.io/t/ohai-plugin-running-external-commands/6120/9 "2014-12-03T20:05:57Z")

</div>

Yes, you can have Fog uses AWS IAM Machine Keys.

Are the tags available via the AWS Metadata API? (169.254.169.254...)  
If so, I'd extend the existing AWS cloud plugin to capture what you  
want; it already interacts with that API endpoint.

cheers,

--aj

On Thu, Dec 4, 2014 at 8:59 AM, Douglas Garstang  
[doug.garstang@gmail.com](mailto:doug.garstang@gmail.com) wrote:

> Don't suppose you know if fog lets you perform AWS operations without an  
> access key/secret access key when the instance belongs to an IAM profile?  
> Can't find specific docs on this, and when I leave them out (which I can do  
> with python boto), it just complains they are missing.
> 
> I'm also installing fog with "gem install fog –no-ri –no-rdoc" and have been  
> waiting about 20 minutes for for "Parsing documentation for fog-1.25.0" to  
> complete on an m3.large EC2 instance. ☹
> 
> Doug.
> 
> On Wed, Dec 3, 2014 at 11:24 AM, Daniel Condomitti [daniel@condomitti.com](mailto:daniel@condomitti.com)  
> wrote:
> 
> > I would recommend using the API directly instead of shelling out to  
> > aws-cli just to parse it back into a machine readable format. Fog[0] is a  
> > good place to start and supports multiple cloud providers if you end up  
> > going down that route. I don’t know for sure that it allows searching by  
> > instance tag (over listing all instances and filtering) but I would expect  
> > that it does.
> > 
> > Dan
> > 
> > [0] [GitHub - fog/fog: The Ruby cloud services library.](https://github.com/fog/fog)
> > 
> > On Wednesday, December 3, 2014 at 1:36 PM, Douglas Garstang wrote:
> > 
> > Dennis,
> > 
> > Of course. It's just translating that into something that ohai runs and  
> > returns as a dictionary that's tricky. The plugin also has to run the aws  
> > cli to get it's environment and role and feed that back into the  
> > describe-instances to get a list of matching instances. It seems like a  
> > rather clunky approach. I certainly don't want to run chef search due to the  
> > whole having-to-have-already run thing, which means the chef client has to  
> > then get run multiple times. Not scalable.
> > 
> > Douglas.
> > 
> > On Wed, Dec 3, 2014 at 10:31 AM, Dennis Lovely [dl@aegisco.com](mailto:dl@aegisco.com) wrote:
> > 
> > You can search with AWS CLI:
> > 
> > ec2-describe-instances --filter "tag:YourTagName=YourRequestedValue"
> > 
> > Is this what you're looking for?
> > 
> > hth
> > 
> > -Dennis
> > 
> > On Wed, Dec 3, 2014 at 10:20 AM, Douglas Garstang  
> > [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com) wrote:
> > 
> > Thanks.
> > 
> > I was actually trying to get a list of ec2 instances having tags with  
> > specific values. I don't want to use chef search due to the requirement that  
> > all the nodes must have successfully completed a chef run first.
> > 
> > Douglas.
> > 
> > On Wed, Dec 3, 2014 at 8:45 AM, Jeremy Mauro [j.mauro@criteo.com](mailto:j.mauro@criteo.com) wrote:
> > 
> > Here is one of our ohai :
> > 
> > lspci = Mixlib::ShellOut.new(
> > 
> > ```
> > 'lspci -m',
> > 
> > ```
> > 
> > \<% if node['platform\_family'] == 'windows' -%\>
> > 
> > ```
> > :cwd => "<%= node[:pciutils][:path] %>",
> > 
> > ```
> > 
> > \<% end -%\>
> > 
> > )
> > 
> > lspci.run\_command
> > 
> > stdout, stderr = [lspci.stdout, lspci.stderr]
> > 
> > From: Douglas Garstang [[mailto:doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)]  
> > Sent: mercredi 3 décembre 2014 17:28  
> > To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > Subject: [chef] Ohai Plugin Running External Commands
> > 
> > Has anyone got any examples of custom ohai plugins calling external shell  
> > commands in ruby and returning the result? Having trouble with it. Need to  
> > pull some EC2 tags into chef (via AWS CLI) and an ohai plugin seemed like  
> > the right idea.
> > 
> > Doug
> > 
> > --  
> > Regards,
> > 
> > Douglas Garstang  
> > [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> > Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> > Cell: +1-805-340-5627
> > 
> > --  
> > Regards,
> > 
> > Douglas Garstang  
> > [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> > Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> > Cell: +1-805-340-5627
> 
> --  
> Regards,
> 
> Douglas Garstang  
> [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> Cell: +1-805-340-5627
