- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: Re: Using Tags for Knife Attributes
- Date: Mon, 28 Jul 2014 08:08:49 -0700
On Saturday, July 26, 2014 at 3:54 AM, Sheppy Reno wrote:
>
Wow, after many hours of trying 'Tags' I accidentally type it all lower
>
case and it magically works, but apparently only when the tag contains
>
only the public IP. So my follow up to this is how do I pull just one
>
of the tags when there are multiple?
>
>
Thanks again,
>
Sheppy
Tags are meant to be an Array of strings. There isn’t really an easy way to
specify a path through a nested data structure that handles Arrays like you
want. For example, suppose you add a new tag to some nodes, and for some
reason the order isn’t the same on all nodes. Then you would have
node1[‘tags’] == [“1.2.3.4”, “my_new_tag”]
node2[‘tags’] == [“my_new_tag”, “2.3.4.5”]
Since you can only refer to array elements by position, there’s no way to
pick a specific tag except by iterating over the elements and inspecting them.
I’d recommend making a custom attribute that’s a Hash instead. In your recipe
code, do:
node.set[“external_ip”] = “1.2.3.4”
And with knife, use
knife ssh QUERY -a external_ip
HTH
--
Daniel DeLeo
Archive powered by MHonArc 2.6.16.