# Run task for specific host

**URL:** <https://forum.ansible.com/t/run-task-for-specific-host/36081>\
**Category:** AWX Project\
**Created:** [December 8, 2021, 10:11am UTC](https://forum.ansible.com/t/run-task-for-specific-host/36081 "2021-12-08T10:11:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony1](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tony1](https://forum.ansible.com/u/Tony1)\
**Post date:** [December 8, 2021, 10:11am UTC](https://forum.ansible.com/t/run-task-for-specific-host/36081/1 "2021-12-08T10:11:32Z")

</div>

I have a playbook that runs against 100 hosts.

However one of these needs a bit of extra attention (an additional task).

Is there a way (other than conditionals) I can run this task against this host only?

Trying to avoid conditionals in the playbook to make it clean and generic.

Cheers

---

<div class="post-metadata">

**Author:** ![Wei-Yen\_Tan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/wei-yen_tan/32/4111_2.png) [@Wei-Yen\_Tan](https://forum.ansible.com/u/Wei-Yen_Tan)\
**Post date:** [December 8, 2021, 2:08pm UTC](https://forum.ansible.com/t/run-task-for-specific-host/36081/2 "2021-12-08T14:08:48Z")

</div>

In template tick prompt on launch on limit. Rub job template and limit to that host

---

<div class="post-metadata">

**Author:** ![Wei-Yen\_Tan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/wei-yen_tan/32/4111_2.png) [@Wei-Yen\_Tan](https://forum.ansible.com/u/Wei-Yen_Tan)\
**Post date:** [December 8, 2021, 2:08pm UTC](https://forum.ansible.com/t/run-task-for-specific-host/36081/3 "2021-12-08T14:08:56Z")

</div>

Run

---

<div class="post-metadata">

**Author:** ![riadhhamdi](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/riadhhamdi/32/614_2.png) [@riadhhamdi](https://forum.ansible.com/u/riadhhamdi)\
**Post date:** [December 8, 2021, 2:43pm UTC](https://forum.ansible.com/t/run-task-for-specific-host/36081/4 "2021-12-08T14:43:23Z")

</div>

You can use **delegate\_to: \<specific\_host\>**

and if you want it to be executed only 1 time by that host , you can add also **run\_once: true**

---

<div class="post-metadata">

**Author:** ![Tony1](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tony1](https://forum.ansible.com/u/Tony1)\
**Post date:** [December 8, 2021, 4:05pm UTC](https://forum.ansible.com/t/run-task-for-specific-host/36081/5 "2021-12-08T16:05:04Z")

</div>

Sorry, I think I haven’t explained what I want very well.

I want to run a generic playbook against 100 hosts which is on an AWX schedule - lets call this **Playbook A**.

However for 1 of the 100 hosts, I also have to run an additional task, but I dont want to include this in Playbook A as I want to keep it as generic as possible.

Is there a clever way to do this, or is it a case of just setting up **Playbook B** for the 1/100 host?

Cheers

---

<div class="post-metadata">

**Author:** ![Wei-Yen\_Tan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/wei-yen_tan/32/4111_2.png) [@Wei-Yen\_Tan](https://forum.ansible.com/u/Wei-Yen_Tan)\
**Post date:** [December 8, 2021, 6:01pm UTC](https://forum.ansible.com/t/run-task-for-specific-host/36081/6 "2021-12-08T18:01:18Z")

</div>

In that case in the task you want to customise. Set a when in it. Assign it a variable like perform\_task\_a = true. ( Your discretion). Then create a host var or group var. And add the var to the host or group. That way the members of the group will be the only ones that get that task. The others will skip
