Run a role once and only once

31 views
Skip to first unread message

Matt Willsher

unread,
Jan 14, 2015, 1:45:30 PM1/14/15
to ansible...@googlegroups.com
Hi,

I have a role that's called from other roles via dependencies. I'm seeing the role run twice, as discussed at https://groups.google.com/forum/#!searchin/ansible-project/role$20dependencies$20run$20twice/ansible-project/qoC1fVKEm7I/MWDl9ALo-KoJ

I've worked around this by adding the following as the last task of the role:

- set_fact: myrole_has_run=true
  when: myrole_has_run is not defined


And then in the meta/defaults.yml:

dependencies:
  - role: myrole
    when: myrole_has_run is not defined

Is there a native way of making sure a role only runs once?

Thanks.
Matt
Reply all
Reply to author
Forward
0 new messages