<p>I am trying to create a Kubernetes cluster with Vagrant using an Ansible playbook that works perfectly on real (linux) servers. I am having a problem with the <code>kubeadm join</code> with vagrant.</p>

<p>I am using the following command to join a node to the cluster.</p>

<pre><code>kubeadm join --token={{ kube_token.stdout }} {{ hostvars[groups['kubemaster'][0]].ansible_default_ipv4.address }}
</code></pre>

<p>The problem with vagrant is that it interprets:</p>

<p><code>hostvars[groups['kubemaster'][0]].ansible_default_ipv4.address</code> </p>

<p>as the <code>enp0s3</code> address which seems to always be <code>10.0.2.15</code> on all machines in my cluster.</p>

<p>I have tried explicitly setting the ip of my machines using:</p>

<pre><code>machine.vm.network :private_network, ip: &lt; ip &gt;, auto_config: false
</code></pre>

<p>but this sets the <code>enp0s8</code> address so it still doesn't work.</p>

<p>How do I make the <code>hostvars[groups['kubemaster'][0]].ansible_default_ipv4.address</code> different on all the machines in my vagrant setup?</p>

<p>you can use <code>hostvars[groups['kubemaster'][0]].ansible_eth1.ipv4.address</code> 
assuming that your eth1 is your actual ip you want.  as noted by Frederic, it uses the default as the first.  you can do <code>ip addr</code> to find your interfaces on a machine.   </p>
