Reputation: 421
I was going through chef, and when this part came where search queries can be put inside the recipe files, I am facing a problem when I try to fetch the secondary IP addresses of a node. When I try to get the primary IP address, I can get is as
>> knife node show web1 -a ipaddress
web1:
ipaddress: 10.0.2.15
But when I try to fetch the secondary IP address, I could see that the key itself is the secondary IP.
>> knife node show web1 -a network.interfaces.eth0.addresses
web1:
network.interfaces.eth0.addresses:
08:00:27:6E:B1:DB:
family: lladdr
192.168.10.43:
broadcast: 192.168.10.255
family: inet
netmask: 255.255.255.0
prefixlen: 24
scope: Global
fe80::a00:27ff:fe6e:b1db:
family: inet6
prefixlen: 64
scope: Link
tags:
How can I extract the secondary IP field directly in this case, which comes as 192.168.10.43
?
Upvotes: 1
Views: 765
Reputation: 54267
knife search
and knife node show
display the full object data and are not intended for scripting. We offer knife exec
for simple Ruby scripts or libraries like chef-api
or PyChef
for more complex things.
Upvotes: 1