0

I'm trying to apply a new configuration to some devices. This new config will also update the management ip of the devices, the same management ip that ansible used to connect to the device. Will the connection break immediately after ansible has configured this new ip without completing the rest of the tasks in the same playbook? Or ansible will complete the rest of the tasks it's supposed to?

Example playbook:

tasks:

    - name: configure mgmt ip
    ......

    - name: configure other interface
    ......

Will it ever complete the task "configure other interface", considering the previous task changed the ip that ansible used to connect to the device?

Mo Fatty
  • 317
  • 2
  • 8
  • Have you tried `- set_fact:` with `ansible_host: "{{ the_new_ip }}"`? I actually don't know if it requires a live connection to execute the `set_fact:` -- I would hope not, but am thankful I've never had to find out – mdaniel Apr 22 '20 at 03:15
  • The question of whether the connection will break depends on the device and how it applies the changes. However, by using a playbook with multiple plays (each one specifying the host and tasks), you can force Ansible to reconnect. As @mdaniel indicated, you can reset the `ansible_host` using `set_fact` if you need to change the address during the process. – gaige Apr 22 '20 at 10:23

0 Answers0