Packer.io - dial tcp 172.X.X.X:22: connect: no route to host

436 views Asked by At

I'm using vsphere-clone as the builder and ansible-playbook as the provisioner to build my machine.

In one of my ansible tasks, I'm rebooting the machine (after installing some packages and changing network interfaces names), but sometimes my VM is getting a different IP address from DHCP and the ansible playbook cannot continue to the rest of the tasks. I tried the ansible.builtin.setup:

- name: do facts module to get latest information
  setup:

But it's not refreshing the IP. Also tried reboot with shell provisioner instead:

{
  "type": "shell",
  "inline": ["echo {{user `ssh_password`}} | sudo -S reboot"],
  "expect_disconnect": true,
  "inline_shebang": "/bin/bash -x"
}

But the next provisioners also uses the old IP. Is there a way with Packer, to refresh the IP?

0

There are 0 answers