Hi Netanel, You can use delegate_to for this.
https://docs.ansible.com/ansible/latest/user_guide/playbooks_delegation.html#delegating-tasks - Rilindo > On Mar 8, 2022, at 4:16 AM, Netanel Peretz <[email protected]> wrote: > > Hey, > I want to be able to use a playbook to run a task on host1 then run a task on > localhost(ansible host) and then run another task on host1 > > > Is that supposed to be as simple as copying something like this and changing > the hostname and the task that comes after that? > Is there a better way to do so? > > > - name: TASKNAME > hosts: host1 > tasks: > > - name: TASK ON HOST1 > shell: <running script> > > - name: TASKNAME > hosts: localhost > tasks: > > - name: TASK ON LOCALHOST > shell: <running script> > > - name: TASKNAME > hosts: host1 > tasks: > > - name: ANTOHER TASK ON HOST1 > shell: <running script> > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/c2236069-81c8-4cf9-a81f-242927b05455n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/A4DD90E4-03ED-4F6F-9E73-E905BFF464C4%40gmail.com.
