Ensuring a command only runs once

1,134 views
Skip to first unread message

Jonathan Rowlands

unread,
Aug 5, 2013, 8:46:24 PM8/5/13
to ansible...@googlegroups.com
Sorry if this has been asked before...  Is there a pattern to ensure a command gets run once and only once on a machine? For instance if I want to seed a database on the initial deploy but I would never want to run this command again.  I have been doing the following:
shell: mycommand && touch somefile creates=somefile

It works but wasn't sure if there was a better way.

Thanks,
Jon 

Michael DeHaan

unread,
Aug 5, 2013, 9:07:36 PM8/5/13
to ansible...@googlegroups.com
Creates is the way to go here!






--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Jonathan Rowlands

unread,
Aug 5, 2013, 9:09:21 PM8/5/13
to ansible...@googlegroups.com
Cool, thanks!

Stefan Eriksson

unread,
Apr 9, 2014, 12:23:49 PM4/9/14
to ansible...@googlegroups.com
hi I have this exact issue but dont understand the anwer "Creates is the way to go here!" could anyone explain in little more detail? thanks.

James Tanner

unread,
Apr 10, 2014, 1:54:26 PM4/10/14
to ansible...@googlegroups.com
> <https://groups.google.com/groups/opt_out>.
>
>
>
>
>
> --
> Michael DeHaan <mic...@ansibleworks.com>
> CTO, AnsibleWorks, Inc.
> http://www.ansibleworks.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 ansible-proje...@googlegroups.com
> <mailto:ansible-proje...@googlegroups.com>.
> To post to this group, send email to ansible...@googlegroups.com
> <mailto:ansible...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d5ed55bf-56c0-4cf1-b782-20c54df47980%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/d5ed55bf-56c0-4cf1-b782-20c54df47980%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

http://docs.ansible.com/shell_module.html

parameter required default choices comments





creates no
a filename, when it already exists, this step will *not* be run.


Reply all
Reply to author
Forward
0 new messages