title: How to get the IP Address in Vagrant?
body: <p>I'm trying to configure a <code>Hadoop</code> cluster, but to do so I needed the ip address of the <code>namenode</code>. 
  The cluster itself is being created by <code>Vagrant</code>, but I don't have the ip address until vagrant creates the instance in AWS.
  So, I have the following <code>Vagrantfile</code>:</p>
  
  <pre><code>current_dir = File.dirname(__FILE__)
  
  $master_script = &lt;&lt;SCRIPT
  // will write a script to configure 
  SCRIPT
  
  Vagrant.configure("2") do |config|
    config.omnibus.chef_version = :latest
  
    config.vm.provider :aws do |aws, override|
      config.vm.box = "dummy"
      aws.access_key_id = "MY_KEY"
      aws.secret_access_key = "SECRET_KEY"
      aws.keypair_name = "my_key"
      aws.ami = "ami-7747d01e"
      override.ssh.username = "ubuntu"
      override.ssh.private_key_path = "#{current_dir}/my_key.pem"
    end
  
    config.vm.provider :virtualbox do |v|
        config.vm.box = "precise64"
        config.vm.box_url =  "https://vagrantcloud.com/chef/ubuntu-13.04/version/1/provider/virtualbox.box"
        v.customize ["modifyvm", :id, "--memory", "1024"]
    end
  
    config.vm.define :namenode do |namenode|
        namenode.vm.box = "dummy"
        namenode.vm.provision :chef_solo do |chef|
           chef.cookbooks_path = "cookbooks"
           chef.roles_path = "roles"
           chef.add_role "cluster"
        end
        namenode.vm.provision :hostmanager
        namenode.vm.provision "shell", :inline =&gt; $master_script
    end
  
  
  
  config.vm.define :slave do |slave|
        slave.vm.box = "dummy"
        slave.vm.provision :chef_solo do |chef|
           chef.cookbooks_path = "cookbooks"
           chef.roles_path = "roles"
           chef.add_role "cluster"
        end
        slave.vm.provision :hostmanager
        slave.vm.provision "shell", :inline =&gt; $master_script
    end
  end
  </code></pre>
  
  <p>I need to update the <code>mapred-site.xml and core-site.xml</code> files with the <code>ip address</code> of the namenode. How could I get the ip address of the <code>namenode</code> box so I can update the hadoop config files? Is there a better option in the cookbook that I can use to accomplish it?
  Suppose I have 1 <code>namenode</code> and 5 <code>slaves</code>, the <code>mapred-site.xml.erb</code> template will look like:</p>
  
  <pre><code>&lt;configuration&gt;
     &lt;property&gt;
        &lt;name&gt;mapred.job.tracker&lt;/name&gt;
        &lt;value&gt;hdfs://&lt;%= node[:ipaddress] %&gt;:8021&lt;/value&gt;
     &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>However, I needed that all the <code>namenode</code> and the <code>slaves</code> to have the ip address only of the <code>namenode</code>. How can I accomplish that in <code>chef</code>? 
  Either way will work for me, even though I prefer the <code>chef</code> solution. </p>