Re: [ansible-project] set_fact on 'meta' playbook

46 views
Skip to first unread message

Michael DeHaan

unread,
Jul 24, 2014, 7:34:09 PM7/24/14
to ansible...@googlegroups.com
Well... sort of, not really.

What happens when you "when" a role, it applies a "when" as the first condition of every task in the role.

So I suspect you have applied the "when" to your "set_fact" :)


All the "is_executed" stuff is generally non-idiomatic, the goal of a playbook is to allow repeated configuration, and should be written to allow reconfiguration or reassertion of configuration reliably.

If there are steps that will fail if rerun, failed_when can be a useful guide, as can conditionals around the stat module, but just guard those specific parts.




On Thu, Jul 24, 2014 at 4:52 PM, Michael Dur <micha...@gmail.com> wrote:
I have a role who's sole purpose is as a meta playbook.
It has a bunch of includes in meta/main.yml:
allow_duplicates: no
dependencies:
  - { role: feature/zypper, when: "common_has_executed is defined" }
  - { role: feature/rc.firewall, when: "common_has_executed is defined" }
  - { role: base/base, when: "common_has_executed is defined" }
  - { role: feature/perl, when: "common_has_executed is defined" }
  - { role: feature/python, when: "common_has_executed is defined" }
  - { role: feature/ruby, when: "common_has_executed is defined" }

I want this to just run once, so I made a task:

- name: log common status
  set_fact:  common_has_executed = "1"

Unfortunately the task seems to be parsed before the meta includes, so nothing runs.

--
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/77f77ecc-29f1-4077-9fd1-78e49dd02eec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages