# Is there a Pattern for having one machine in a cluster perform an action?

**URL:** <https://forum.ansible.com/t/is-there-a-pattern-for-having-one-machine-in-a-cluster-perform-an-action/15890>\
**Category:** Ansible Project\
**Created:** [August 8, 2014, 2:08pm UTC](https://forum.ansible.com/t/is-there-a-pattern-for-having-one-machine-in-a-cluster-perform-an-action/15890 "2014-08-08T14:08:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Matz1](https://avatars.discourse-cdn.com/v4/letter/g/b5e925/32.png) [@Guy\_Matz1](https://forum.ansible.com/u/Guy_Matz1)\
**Post date:** [August 8, 2014, 2:08pm UTC](https://forum.ansible.com/t/is-there-a-pattern-for-having-one-machine-in-a-cluster-perform-an-action/15890/1 "2014-08-08T14:08:35Z")

</div>

Hi! I have a few django servers . . . I would like to run a syncdb in my playbook, but only need/want one of the django servers in the group to run that play . . . do I need to designate a machine to run that or is there an easier way?

Thanks!!

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [August 8, 2014, 2:15pm UTC](https://forum.ansible.com/t/is-there-a-pattern-for-having-one-machine-in-a-cluster-perform-an-action/15890/2 "2014-08-08T14:15:09Z")

</div>

Ansible 1.7 added the new "run\_once" keyword so that a given action  
will only run once for that host list.

---

<div class="post-metadata">

**Author:** ![Guy\_Matz1](https://avatars.discourse-cdn.com/v4/letter/g/b5e925/32.png) [@Guy\_Matz1](https://forum.ansible.com/u/Guy_Matz1)\
**Post date:** [August 8, 2014, 2:33pm UTC](https://forum.ansible.com/t/is-there-a-pattern-for-having-one-machine-in-a-cluster-perform-an-action/15890/3 "2014-08-08T14:33:43Z")

</div>

Super-sweet! For anyone who is wondering, the “full” documentation is in here: [http://docs.ansible.com/playbooks\_delegation.html](http://docs.ansible.com/playbooks_delegation.html)

Thanks!!!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 8, 2014, 11:25pm UTC](https://forum.ansible.com/t/is-there-a-pattern-for-having-one-machine-in-a-cluster-perform-an-action/15890/4 "2014-08-08T23:25:18Z")

</div>

run\_once does that for a task, yes.

Long-form, may be useful, as well;

# all of em

- hosts: webservers  
tasks:
- blarg
- blarg

# just on the head node

- hosts: webservers[0]  
tasks:
- blarg
- blarg

# now some others

- hosts: dbservers  
tasks:
- blarg
