# how to run specific task locally on ansible ?

**URL:** <https://forum.ansible.com/t/how-to-run-specific-task-locally-on-ansible/32996>\
**Category:** Ansible Project\
**Created:** [May 21, 2020, 3:00pm UTC](https://forum.ansible.com/t/how-to-run-specific-task-locally-on-ansible/32996 "2020-05-21T15:00:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinod\_devops](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vinod\_devops](https://forum.ansible.com/u/vinod_devops)\
**Post date:** [May 21, 2020, 3:00pm UTC](https://forum.ansible.com/t/how-to-run-specific-task-locally-on-ansible/32996/1 "2020-05-21T15:00:22Z")

</div>

there are no of tasks in play book,

all tasks are running remotely on host. I want to run only one task locally.

How do I do that ? Thanks

---

<div class="post-metadata">

**Author:** ![Vivek\_Kothawale](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@Vivek\_Kothawale](https://forum.ansible.com/u/Vivek_Kothawale)\
**Post date:** [May 21, 2020, 3:05pm UTC](https://forum.ansible.com/t/how-to-run-specific-task-locally-on-ansible/32996/2 "2020-05-21T15:05:13Z")

</div>

Hi

Use tags to achieve this.

Thanks,  
Vivek

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [May 21, 2020, 3:07pm UTC](https://forum.ansible.com/t/how-to-run-specific-task-locally-on-ansible/32996/3 "2020-05-21T15:07:07Z")

</div>

> there are no of tasks in play book,
> 
> all tasks are running remotely on host. I want to run only one task locally.
> 
> How do I do that ? Thanks

- name: ...  
&nbsp;&nbsp;....  
&nbsp;&nbsp;delegate\_to: localhost

You may also add the following:

&nbsp;&nbsp;run\_once: true

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Suneel\_Gali](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@Suneel\_Gali](https://forum.ansible.com/u/Suneel_Gali)\
**Post date:** [May 21, 2020, 3:36pm UTC](https://forum.ansible.com/t/how-to-run-specific-task-locally-on-ansible/32996/4 "2020-05-21T15:36:17Z")

</div>

You can use:

`local_action` or `delegate_to: localhost` at task level.

-Suneel

---

<div class="post-metadata">

**Author:** ![vinod\_devops](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vinod\_devops](https://forum.ansible.com/u/vinod_devops)\
**Post date:** [May 22, 2020, 4:20am UTC](https://forum.ansible.com/t/how-to-run-specific-task-locally-on-ansible/32996/5 "2020-05-22T04:20:43Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![vinod\_devops](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vinod\_devops](https://forum.ansible.com/u/vinod_devops)\
**Post date:** [May 22, 2020, 4:21am UTC](https://forum.ansible.com/t/how-to-run-specific-task-locally-on-ansible/32996/6 "2020-05-22T04:21:08Z")

</div>

Thank you!
