0

I have two hosts which I want to setup with Ansible. Each host is assigned a role (host1: r1 and host2: r2). I run the configurations in one playbook.

Description: Both roles run multiple tasks, but at some point r2 needs to wait (pause execution of remaining tasks) until a file is created on host1 by r1. When the file is created, I plan to copy the file from r1 to the Ansible master and then r2 should be notified to continue executing the remaining tasks, which starts by copying the file to r2.

How can I do that? I thuoght about handlers but I dont now how to block the execution of tasks until a event happens (file was created and copied to master)

- Thanks

  • 1
    The question is quite broad but you can have a look at the [`wait_for` module](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_module.html) – Zeitounator May 02 '21 at 18:12
  • I saw the wait_for module, but in my understanding, I can only wait for file creation on the target host. In my case I need to wait on a file to be created on the "master" host. Is that somehow possible with that module? – StuckAgain May 02 '21 at 18:17
  • `I plan to copy the file from r1 to the Ansible master` => `wait_for: .... delegate_to: localhost` – Zeitounator May 03 '21 at 04:18
  • Thanks, `wait_for` together with `delegate_to` seems to be the right thing. I will give it a try! – StuckAgain May 03 '21 at 11:26

0 Answers0