Search within a template


#1

Hi,

Is it possible to perform a search within a template file?
Ie
search(:node, “role:web-server”)

I’ve come across Chef::Search::Query but not sure if that’s what I should be using. Passing the search results into the template as a variable won’t work for what I’m trying to do.

Partial_search would be better, but I’ll settle for search!

Thanks
Tom

HBVB trading as Bauer Corporate Services (BCS) is a division of the Bauer Media
Group the largest consumer publisher in the UK, and second largest commercial
radio broadcaster. BCS provides financial services and manages and develops IT
systems on which our UK publishing, broadcast, digital and partner businesses depend.

The information in this email is intended only for the addressee(s) named above.
Access to this email by anyone else is unauthorised. If you are not the intended
recipient of this message any disclosure, copying, distribution or any action
taken in reliance on it is prohibited and may be unlawful. HBVB do not warrant that
any attachments are free from viruses or other defects and accept no liability for
any losses resulting from infected email transmissions.

Please note that any views expressed in this email may be those of the originator
and do not necessarily reflect those of this organisation.

HBVB is registered in England; Registered address is
1 Lincoln Court, Lincoln Road, Peterborough, PE1 2RF.

Registration number 8453545


#2

It can be done using the class, but please don’t. It leads to unreadable templates, and makes it really hard to know where data is coming from. Do the search in the recipe, and pass the results in as template variables, and you’ll be much happier for it.

–Noah

On Jun 24, 2014, at 2:58 PM, “Deprez, Tom” tom.deprez@bauerservices.co.uk wrote:

Hi,

Is it possible to perform a search within a template file?
Ie
search(:node, “role:web-server”)

I’ve come across Chef::Search::Query but not sure if that’s what I should be using. Passing the search results into the template as a variable won’t work for what I’m trying to do.

Partial_search would be better, but I’ll settle for search!

Thanks
Tom

HBVB trading as Bauer Corporate Services (BCS) is a division of the Bauer Media
Group the largest consumer publisher in the UK, and second largest commercial
radio broadcaster. BCS provides financial services and manages and develops IT
systems on which our UK publishing, broadcast, digital and partner businesses depend.

The information in this email is intended only for the addressee(s) named above.
Access to this email by anyone else is unauthorised. If you are not the intended
recipient of this message any disclosure, copying, distribution or any action
taken in reliance on it is prohibited and may be unlawful. HBVB do not warrant that
any attachments are free from viruses or other defects and accept no liability for
any losses resulting from infected email transmissions.

Please note that any views expressed in this email may be those of the originator
and do not necessarily reflect those of this organisation.

HBVB is registered in England; Registered address is
1 Lincoln Court, Lincoln Road, Peterborough, PE1 2RF.

Registration number 8453545


#3

Thanks Noah,

Having slept on it I think this is the way I’ll have to go.

Tom

-----Original Message-----
From: Noah Kantrowitz [mailto:noah@coderanger.net]
Sent: 24 June 2014 23:00
To: chef@lists.opscode.com
Subject: [chef] Re: Search within a template

It can be done using the class, but please don’t. It leads to unreadable templates, and makes it really hard to know where data is coming from. Do the search in the recipe, and pass the results in as template variables, and you’ll be much happier for it.

–Noah

On Jun 24, 2014, at 2:58 PM, “Deprez, Tom” tom.deprez@bauerservices.co.uk wrote:

Hi,

Is it possible to perform a search within a template file?
Ie
search(:node, “role:web-server”)

I’ve come across Chef::Search::Query but not sure if that’s what I should be using. Passing the search results into the template as a variable won’t work for what I’m trying to do.

Partial_search would be better, but I’ll settle for search!

Thanks
Tom

HBVB trading as Bauer Corporate Services (BCS) is a division of the
Bauer Media Group the largest consumer publisher in the UK, and second
largest commercial radio broadcaster. BCS provides financial services
and manages and develops IT systems on which our UK publishing, broadcast, digital and partner businesses depend.

The information in this email is intended only for the addressee(s) named above.
Access to this email by anyone else is unauthorised. If you are not
the intended recipient of this message any disclosure, copying,
distribution or any action taken in reliance on it is prohibited and
may be unlawful. HBVB do not warrant that any attachments are free
from viruses or other defects and accept no liability for any losses resulting from infected email transmissions.

Please note that any views expressed in this email may be those of the
originator and do not necessarily reflect those of this organisation.

HBVB is registered in England; Registered address is
1 Lincoln Court, Lincoln Road, Peterborough, PE1 2RF.

Registration number 8453545