[chef] Re: Re: Re: Re: Fwd: Unable to use data bag


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Fwd: Unable to use data bag
  • Date: Mon, 30 Sep 2013 11:07:00 -0700


On Monday, September 30, 2013 at 11:05 AM, Cassiano Leal wrote:

Yep. So the catch here is that the search will always return an Array of all the items that matched the search criteria.

If the only item matching is your one data bag, it will return

[
  {
    “id”: “uas-replicaset-1”,
    …
  }
]

In which case calling .first() on it will have the desired result as it will return only the first (and in this case, the only one) item of the Array.

Problems might arise if your search returns more than one item, in which case you’d be discarding all but the first.
If you know what item you want, you can use the #data_bag_item method to fetch it directly instead of through search.


-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§