Hi,

i would like to continue some discussion around this issue reported on 
GitHub:
https://github.com/ansible/ansible/issues/72646

I was thinking about in some complex ansible codes (many roles),
that variables structured inside roles make sense to be sort of namespaced,
like for example grouping them in a root role variable as same for the role:

---
## roleA/default/main.yml
roleA:
  varA: 'a'
  varB: 'b'


when overriding only for eg varB when using the role, can be used as 
reported in that ticket, set_facts in conjunction with combine filter for 
eg. 
It is ok, as a workaround, but it seems requires some extra work for a 
simple operation from the user perspective, that compare to the merge hash 
behavior

Alternatively, would it be possible to access nested variable with the '.' 
dot operation like for Jinja templates? eg: 
--- 
roles:
    role:
    -  roleA:
       vars:
          roleA.varB: 'be'


this kind of syntax will produce invalid key as it is not possible to 
address it.

Basically what I came from is to have a little bit more closer to a simple 
statement assignment of a programming language rather than configuration as 
it seems to me simpler to achieve some wanted results. 

Otherwise this impossibility, could potentially lead to have variables with 
longer name,
rather than grouping in sub keys (with the '.') using underscores:

---
## roleA/default/main.yml
roleA_varA: 'a'
roleA_varB: 'b'

could still working to achieve some "unique naming for roles variables", 
but it could be quite verbose.

So basically i am just sharing a thought/consideration if it would be 
feasible an improvement on addressing yaml key for variable to process as 
well the dot operator like the 2nd example above (and reporting here again 
for clarity):
--- 
roles:
    role:
    -  roleA:
       vars:
          roleA.varB: 'be'  

-- 
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-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/842066ca-631f-4ee6-8d72-6e1fca1f4231n%40googlegroups.com.

Reply via email to