I created a role with default variables using a nested syntax and not I’d like to override just a few of those attributes in the playbook, but whenever I do it I end up redefining the entire variable na loosing the defaults for the non overrided values.
There is a variable merging setting, but I prefer being explicit about
having a complex variable, parts of which can be overridden (rather
than magically "doing the right thing").
Thanks for the suggestion, but the problem remains. You haven’t override the default value, but instead declared a second flat variable. The problem with this approach is that if do this for every paramet I’ll double the number of used variables. Also I will have to “flatten” them all which in practice would be easier to just flatten the defaults.
But I do wish to have the nested syntax because some of my variables become very confusing when flattening and I also found it better for organization and clarity in the yml.
Michael, after reading the ansible.cfg documentation page, I found the parameter you mentioned, together with an warning against it. Since I value the experience from everyone here more than mine, would you care to explain why merging the hashes could be such bad idea?
Thanks again.
ps.: not trying to raise a flame, just like to hear about it.
I'm not sure which warning that is, but I can confirm you I have been
using the merge functionality for a long time, and do not experience any
problems with it.
Of course you have to remember or take into account where you define
(different parts of) those hashes, and understand the possible
implications.