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
.
Author by
Frexin
Updated on July 09, 2022Comments
-
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 over 8 yearsBut it's not possible to delegate whole playbook, not one task. Or maybe can i use another 'become_user' for such delegated task?
-
nghnam over 8 years@Frexin : You can delegate a whole playbook with using delegate to the localhost ( ansible master) and calling
ansible-playbook
command.