Chef use different IP Address

chef

Just moved from Amazon to Joyent (doesn't matter why) and setting up my Chef Server I found following problem:

As you may know, Chef sets the IP address according to the route table. So in my case, the IP informed from the client to the server is my public IP.

I've a recipe to dynamically write the /etc/hosts file, using the IP and FQDN informed from the client. The problem, is that I need to use the private IP so all traffic reach a local machine will be, in fact, local.

I tried using node['network']['ipaddress_eth1'] on hosts.erb template file, but is not working.

What cloud I be missing? Is there any other way to write my hosts file using my private IP?

Thanks

Update

There's actually a way to find what I'm looking for, using shef:

chef > asdf = node['network']['interfaces']['eth1']['addresses'].keys.select { |a| a[/\A\d+\.\d+\.\d+\.\d+\Z/] }.first

This will return the IP address on my eth1.

Best Answer

To solve this problem I used the ipaddr_extensions gem and then add privateipaddress attribute to ohai.