Ansible: how to run task on other host inside one playbook?

20,655

If you want to run a task that's associated with a host, but on different host, you should try delegate_to.

Share:
20,655
Frexin
Author by

Frexin

Updated on July 09, 2022

Comments

  • Frexin
    Frexin almost 2 years

    I'm writing ansible playbook for one specific goal: i'd like to sync directory on server A-n, but before i should make git pull on server "B". I launch playbook on host A-n (described in inventory). I also have playbook for "git pull" on server B. Is it possible to include one playbook in another? I don't know how, because ansible allow to specify only one host group in beginning of playbook.

  • Frexin
    Frexin over 8 years
    But it's not possible to delegate whole playbook, not one task. Or maybe can i use another 'become_user' for such delegated task?
  • nghnam
    nghnam over 8 years
    @Frexin : You can delegate a whole playbook with using delegate to the localhost ( ansible master) and calling ansible-playbook command.