I used to define variables in the following way:
---
mysql:
config:
bind_address: 127.0.0.1
root:
password: ''
remote_access: absent
This style of writing is appealing to read and non repititive. Inside
the artifacts of the role I can reference such variables like {{ mysql.root.password }}.
However I am not able to override those variables by referencing them
the same way from other roles, playbooks or the console. It took me some
hours to find out, that the access of complex variables is not conform
all over Ansible, which mades me working with Ansible more difficult. Even If i declare hash_behavior as merge, following will not work:
ansible-playbook -e "role=thomass.mysql docker.ports=['3306'] mysql.config.bind_address=0.0.0.0 mysql.root.password=letmein mysql.root.remote_access=present" --ask-sudo-pass site.yml
mysql_config_bindAddress: 127.0.0.1
mysql_root_password: ''
mysql_root_remoteAccess: absent
But this style is not as readable as the one from above and you have to repeat the whole thought path for every variable.
Is it worth to think about making the variable access to the upper variable definition uniform all over Ansible? Not just because of the better variable definition style but also because of the more intuitive usage of Ansible.