also sprach Michael DeHaan <michael@ansibleworks.com> [2013.06.12.1301 +0200]:
As I posted on May 24th, "group_vars" is a great place to stick
defaults, and as of 1.2, they can also live in your playbook
directory.
But neither of those are under control of the author of a role, and
since roles are supposed to encourage reuse of work, they need to be
self-contained.
However, there's nothing to say you can't set parameters to the role in
your playbook, like so, too... and is a great way to pass required
parameters:
roles:
- { role: foo, x: 42, y: asdf.example.com }
Yes, I am aware of this, although I wonder about the difference in
syntax between this and the way includes get parametrised.
Using this approach, it is possible to override role parameters
per-playbook, and hence for the group(s) to which the playbook
applies.
However, if the playbook applies to two groups and you want to
specify different parameters for each group, or you want to be able
to use host-specific parameters, you have to resort to something
like
- { role: foo, x: 42, ntp_server: $my_url }
and define $my_url in group_vars/host_vars, rather than just
defining $ntp_server there. That's an extra level of indirection and
hence an extra source of error and confusion…
We're not going to be changing the order of inventory precedence.
I am not asking you to do that, especially not what is documented
already. However, roles are a new concept, and they aren't even
included in the docs on variable precedence yet. Therefore, I don't
think we are looking to change existing behaviour, but rather
discussing a new feature. And I think that the way this feature
currently interacts with variable precedence is non-intuitive and
suboptimal.
Am I not succeeding in describing why, and what could be done
instead?