Searching with chef

Hi guys -

I’m struggling a bit with searching within chef…

I’m trying to select all nodes that have a given role in a particular
environment.

I realize I can do something like:

knife search node “roles:” -E

But how do I get things like the ip address from that object?

Try this:

knife search node "roles: AND
'chef_environment:" -a ipaddress

-M

On Mon, Mar 4, 2013 at 6:08 PM, Maven User maven.2.user@gmail.com wrote:

Hi guys -

I'm struggling a bit with searching within chef...

I'm trying to select all nodes that have a given role in a particular
environment.

I realize I can do something like:

knife search node "roles:" -E

But how do I get things like the ip address from that object?

on the CLI, you can pass the '-a / --attribute' flag to get a
particular attribute tree from the object.

In the recipe, it'll look something like

servers = search(:node, "roles:bar AND chef_environment:production")
server = servers.first
ip = server['ipaddress'] # Just a Chef::Node object here.

Check out Heavy Water's discovery cookbook for some recipe helpers,
like 'empty ok?', local node fall-back, environment aware search, sort
by check-in time & cloud-aware IP addressing preferences. [0]

--AJ

[0] http://ckbk.it/discovery

On 5 March 2013 12:08, Maven User maven.2.user@gmail.com wrote:

Hi guys -

I'm struggling a bit with searching within chef...

I'm trying to select all nodes that have a given role in a particular
environment.

I realize I can do something like:

knife search node "roles:" -E

But how do I get things like the ip address from that object?

I wonder if we should move some of that into the core DSL. Super useful,
non intrusive.

Adam

On 3/4/13 3:12 PM, "AJ Christensen" aj@junglist.gen.nz wrote:

on the CLI, you can pass the '-a / --attribute' flag to get a
particular attribute tree from the object.

In the recipe, it'll look something like

servers = search(:node, "roles:bar AND chef_environment:production")
server = servers.first
ip = server['ipaddress'] # Just a Chef::Node object here.

Check out Heavy Water's discovery cookbook for some recipe helpers,
like 'empty ok?', local node fall-back, environment aware search, sort
by check-in time & cloud-aware IP addressing preferences. [0]

--AJ

[0] http://ckbk.it/discovery

On 5 March 2013 12:08, Maven User maven.2.user@gmail.com wrote:

Hi guys -

I'm struggling a bit with searching within chef...

I'm trying to select all nodes that have a given role in a particular
environment.

I realize I can do something like:

knife search node "roles:" -E

But how do I get things like the ip address from that object?

+1 for environment scoped searches.

On Tue, Mar 5, 2013 at 10:37 AM, Adam Jacob adam@opscode.com wrote:

I wonder if we should move some of that into the core DSL. Super useful,
non intrusive.

Adam

On 3/4/13 3:12 PM, "AJ Christensen" aj@junglist.gen.nz wrote:

on the CLI, you can pass the '-a / --attribute' flag to get a
particular attribute tree from the object.

In the recipe, it'll look something like

servers = search(:node, "roles:bar AND chef_environment:production")
server = servers.first
ip = server['ipaddress'] # Just a Chef::Node object here.

Check out Heavy Water's discovery cookbook for some recipe helpers,
like 'empty ok?', local node fall-back, environment aware search, sort
by check-in time & cloud-aware IP addressing preferences. [0]

--AJ

[0] http://ckbk.it/discovery

On 5 March 2013 12:08, Maven User maven.2.user@gmail.com wrote:

Hi guys -

I'm struggling a bit with searching within chef...

I'm trying to select all nodes that have a given role in a particular
environment.

I realize I can do something like:

knife search node "roles:" -E

But how do I get things like the ip address from that object?

There is also:

http://community.opscode.com/cookbooks/helpers-search

From: Ranjib Dey <dey.ranjib@gmail.commailto:dey.ranjib@gmail.com>
Reply-To: "chef@lists.opscode.commailto:chef@lists.opscode.com" <chef@lists.opscode.commailto:chef@lists.opscode.com>
Date: Tuesday, March 5, 2013 1:47 PM
To: "chef@lists.opscode.commailto:chef@lists.opscode.com" <chef@lists.opscode.commailto:chef@lists.opscode.com>
Subject: [chef] Re: Re: Re: searching with chef

+1 for environment scoped searches.

On Tue, Mar 5, 2013 at 10:37 AM, Adam Jacob <adam@opscode.commailto:adam@opscode.com> wrote:
I wonder if we should move some of that into the core DSL. Super useful,
non intrusive.

Adam

On 3/4/13 3:12 PM, "AJ Christensen" <aj@junglist.gen.nzmailto:aj@junglist.gen.nz> wrote:

on the CLI, you can pass the '-a / --attribute' flag to get a
particular attribute tree from the object.

In the recipe, it'll look something like

servers = search(:node, "roles:bar AND chef_environment:production")
server = servers.first
ip = server['ipaddress'] # Just a Chef::Node object here.

Check out Heavy Water's discovery cookbook for some recipe helpers,
like 'empty ok?', local node fall-back, environment aware search, sort
by check-in time & cloud-aware IP addressing preferences. [0]

--AJ

[0] http://ckbk.it/discovery

On 5 March 2013 12:08, Maven User <maven.2.user@gmail.commailto:maven.2.user@gmail.com> wrote:

Hi guys -

I'm struggling a bit with searching within chef...

I'm trying to select all nodes that have a given role in a particular
environment.

I realize I can do something like:

knife search node "roles:" -E

But how do I get things like the ip address from that object?

I would be on-board with that; Discovery has always been positioned
this way. Potentially with support for Partial searches?

--AJ

On 6 March 2013 07:37, Adam Jacob adam@opscode.com wrote:

I wonder if we should move some of that into the core DSL. Super useful,
non intrusive.

Adam

On 3/4/13 3:12 PM, "AJ Christensen" aj@junglist.gen.nz wrote:

on the CLI, you can pass the '-a / --attribute' flag to get a
particular attribute tree from the object.

In the recipe, it'll look something like

servers = search(:node, "roles:bar AND chef_environment:production")
server = servers.first
ip = server['ipaddress'] # Just a Chef::Node object here.

Check out Heavy Water's discovery cookbook for some recipe helpers,
like 'empty ok?', local node fall-back, environment aware search, sort
by check-in time & cloud-aware IP addressing preferences. [0]

--AJ

[0] http://ckbk.it/discovery

On 5 March 2013 12:08, Maven User maven.2.user@gmail.com wrote:

Hi guys -

I'm struggling a bit with searching within chef...

I'm trying to select all nodes that have a given role in a particular
environment.

I realize I can do something like:

knife search node "roles:" -E

But how do I get things like the ip address from that object?

Oh yeah - I just assumed you were already on the partial search train. You
heavywater guys sure are lazy!

:slight_smile:

Love,
Adam

On 3/5/13 11:33 AM, "AJ Christensen" aj@junglist.gen.nz wrote:

I would be on-board with that; Discovery has always been positioned
this way. Potentially with support for Partial searches?

--AJ

On 6 March 2013 07:37, Adam Jacob adam@opscode.com wrote:

I wonder if we should move some of that into the core DSL. Super useful,
non intrusive.

Adam

On 3/4/13 3:12 PM, "AJ Christensen" aj@junglist.gen.nz wrote:

on the CLI, you can pass the '-a / --attribute' flag to get a
particular attribute tree from the object.

In the recipe, it'll look something like

servers = search(:node, "roles:bar AND chef_environment:production")
server = servers.first
ip = server['ipaddress'] # Just a Chef::Node object here.

Check out Heavy Water's discovery cookbook for some recipe helpers,
like 'empty ok?', local node fall-back, environment aware search, sort
by check-in time & cloud-aware IP addressing preferences. [0]

--AJ

[0] http://ckbk.it/discovery

On 5 March 2013 12:08, Maven User maven.2.user@gmail.com wrote:

Hi guys -

I'm struggling a bit with searching within chef...

I'm trying to select all nodes that have a given role in a particular
environment.

I realize I can do something like:

knife search node "roles:" -E

But how do I get things like the ip address from that object?

boo :frowning:

--AJ

On 6 March 2013 08:39, Adam Jacob adam@opscode.com wrote:

Oh yeah - I just assumed you were already on the partial search train. You
heavywater guys sure are lazy!

:slight_smile:

Love,
Adam

On 3/5/13 11:33 AM, "AJ Christensen" aj@junglist.gen.nz wrote:

I would be on-board with that; Discovery has always been positioned
this way. Potentially with support for Partial searches?

--AJ

On 6 March 2013 07:37, Adam Jacob adam@opscode.com wrote:

I wonder if we should move some of that into the core DSL. Super useful,
non intrusive.

Adam

On 3/4/13 3:12 PM, "AJ Christensen" aj@junglist.gen.nz wrote:

on the CLI, you can pass the '-a / --attribute' flag to get a
particular attribute tree from the object.

In the recipe, it'll look something like

servers = search(:node, "roles:bar AND chef_environment:production")
server = servers.first
ip = server['ipaddress'] # Just a Chef::Node object here.

Check out Heavy Water's discovery cookbook for some recipe helpers,
like 'empty ok?', local node fall-back, environment aware search, sort
by check-in time & cloud-aware IP addressing preferences. [0]

--AJ

[0] http://ckbk.it/discovery

On 5 March 2013 12:08, Maven User maven.2.user@gmail.com wrote:

Hi guys -

I'm struggling a bit with searching within chef...

I'm trying to select all nodes that have a given role in a particular
environment.

I realize I can do something like:

knife search node "roles:" -E

But how do I get things like the ip address from that object?