[chef] Re: Re: Deleting an element in an attribute?


Chronological Thread 
  • From: Max Gorbul < >
  • To:
  • Subject: [chef] Re: Re: Deleting an element in an attribute?
  • Date: Wed, 1 Feb 2012 16:19:46 -0800

... or you can modify the array 

node.normal_attrs[:packages_install_specific].reject! {|p| p[0] == "libicu-devel" }

--max

On Wed, Feb 1, 2012 at 4:16 PM, Ian Marlier < "> > wrote:
What if you make it a hash instead of a list?

set[:packages_install_specific] = {
  "js" => "1.70-8",
  "icu" => "3.6-5.16.1",
...
}

Then you can do, eg, node.normal_attrs[:packages_install_specific].delete("js")




On Wed, Feb 1, 2012 at 7:05 PM, Robert Keng < " target="_blank"> > wrote:
I'm probably not using the right terms, but lets' say I have the following:

set[:packages_install_specific] = [
  ["js","1.70-8"],
  ["icu","3.6-5.16.1"],
  ["libicu","3.6-5.16.1"],
  ["libicu-devel","3.6-5.16.1"]
]

The attrs looks like:
{
    "normal": {
     "packages_install_specific": [
        [
          "js",
          "1.70-8"
        ],
        [
          "icu",
          "3.6-5.16.1"
        ],
        [
          "libicu",
          "3.6-5.16.1"
        ],
        [
          "libicu-devel",
          "3.6-5.16.1"
        ]
     ]

...

Is it possible to delete the tuple   ["libicu-devel","3.6-5.16.1"] programmatically in a recipe? I've tried using:

node.normal_attrs[:packages_install_specific].delete(:libicu-devel) rescue nil

But I probably can't refer to it as a key...Can someone shed some light on this? If someone can forward me to some docs I'd greatly appreciate it. Running 0.9.x (8 I believe), thanks in advance!

-Robert



--
Ian Marlier | Senior Systems Engineer
Brightcove, Inc.





Archive powered by MHonArc 2.6.16.

§