I like the idea, but I don't like the proposal. I would do the same thing, but the other way around. With your proposal it would break backward compatibility with 1.9 if you don't update all your includes, or update ansible.ini. Also most of the includes are static anyway (since dynamic ones didn't work pre 2.0), so why not make them all static by default.
My proposal is to make all includes static by default and introduce a new keyword dynamic: yes (or use static: no if you like it more) which you would set on includes where you need them to be dynamic. This would make old 1.9 playbooks backward compatible without any changes anywhere, and if you need a dynamic include in a 2.0 playbook, you will need to change it in just a few places (since there are far less 2.0 playbooks anyway and even lower number of dynamic includes).
What issues are there with dynamic includes except for included files
which do not do anything?
Because we do not load the included file until we reach that point in the execution, we no longer know anything about the tasks contained within that file. This means that we don't know about tags on those tasks, and notifying handlers within those files do not work either (which breaks a common use case for many people).
--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I also agree it would have made more sense if the dynamic include was optional and the default behavior was the version 1 way. But I also see how this is hard to justify now that Ansible 2 works as it does, it's hard to go back. If Ansible follows semver that would actually mean we have Ansible 3 knocking on our door if the behavior is switched back.Ideally, in my opinion, the new functionality would have been added with a different name, for example "import" instead of "include". This would have allowed a clean way to migrate without breaking things. It also makes it possible to distinguish between two complete different features by name.
We have adopted Ansible 2 but I would not mind if the behavior changed back to the old static include. In any case, I will adjust our roles. Most of the includes do not need to be dynamic and I would set them to static just to get rid of the hundreds blue include statements during playtime.Now, I'm wondering what happens if a static include includes a file which has a dynamic include. :)
I certainly don't want to see dynamic includes go away.
Assuming the preprocessing and running code is neatly split, how about:
1. Preprocess "static" includes - which can be identified by the absence of J2 constructs in them
2. Dynamically preprocess dynamic includes and run them as currently.
3. Add a "dynamic: yes" flag which optionally adds the dynamic behaviour for things that look like static includes.
- include: "{{ some_var }}.yml"
static: yes
- include: "{{ some_var }}.yml"
static: no
So basically now simple includes without any loops or variables in file name will be static by default? That is great news, since most of the includes are like that and it makes them at least backward compatible with 1.x.Could anyone tell me what exactly is the difference between:
- include: "{{ some_var }}.yml"
static: yes
and
- include: "{{ some_var }}.yml"
static: no
Does it mean for static: yes that some_var would need to be defined statically as a var, and for static: no some_var could be defined during play execution, e.g. set_fact: some_var=something.
Timothy Appnel
Principal Architect
Ansible by Red Hat
So many things are broken with Ansible's notion of "composability" that it's hard to know where to begin.