[chef] Re: Getting the ipaddress of a specific interface


Chronological Thread 
  • From: Bryan McLellan < >
  • To:
  • Subject: [chef] Re: Getting the ipaddress of a specific interface
  • Date: Sun, 14 Aug 2011 17:15:26 -0700


On Aug 14, 2011 1:49 PM, "Haim Ashkenazi" < "> > wrote:
> I was wondering if there's an easy way to get the ip address of a specific interface (and not just the main ip adders)?

It isn't as easy as it should be, but you can use this code to do it:

http://tickets.opscode.com/browse/OHAI-88

ipaddress_eth1 = host["network"]["interfaces"]["eth1"]["addresses"].select { |address, data| data["family"] == "inet" }[0][0]

Bryan




Archive powered by MHonArc 2.6.16.

§