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

44 views
Skip to first unread message

Guy Matz

unread,
Aug 8, 2014, 10:08:35 AM8/8/14
to ansible...@googlegroups.com
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!!

Michael Peters

unread,
Aug 8, 2014, 10:15:16 AM8/8/14
to ansible...@googlegroups.com
Ansible 1.7 added the new "run_once" keyword so that a given action
will only run once for that host list.
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0253c2bf-768c-42ce-aa46-e5d0618cd09c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Guy Matz

unread,
Aug 8, 2014, 10:33:43 AM8/8/14
to ansible...@googlegroups.com
Super-sweet!  For anyone who is wondering, the "full" documentation is in here: http://docs.ansible.com/playbooks_delegation.html

Thanks!!!!!

Michael DeHaan

unread,
Aug 8, 2014, 7:25:22 PM8/8/14
to ansible...@googlegroups.com
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




Reply all
Reply to author
Forward
0 new messages