I have a problem with implementing Ansible nested reference YAML variable file.
Example of user dictionary file variable:
User dictionary file variable,
dev_infra_bastion_0_example_comis node FQDN name# user varialbe file root@dev-infra-bastion-0:~/ansible-stats# hostname dev-infra-bastion-0.example.comvars/user.yml
dev_infra_bastion_0_example_com: admin: - admin1 - admin2 - admin3 people: - peopl1 - peopl2 - peopl3I want to pass the dictionary defined in the vars/user.yml file after parsing through this playbook
## create hosts user - hosts: test1 become: yes vars_files: - vars/user.yml pre_tasks: - name: debug debug: msg: "{{ ansible_nodename.replace('-','_').replace('.','_') }}" register: mess - name: debug mess debug: msg: "{{ mess }}"Run info
PLAY [test1] ******************************************************************************************************************************************************************************************************* TASK [debug] ******************************************************************************************************************************************************************************************************* ok: [10.1.204.100] => { "msg": "dev_infra_bastion_0_example_com" } TASK [debug mess] ************************************************************************************************************************************************************************************************** ok: [10.1.204.100] => { "msg": { "changed": false, "failed": false, "msg": "dev_infra_bastion_0_example_com" #Here,Should be a dictionary,but it's string } } PLAY RECAP ********************************************************************************************************************************************************************************************************* 10.1.204.100 : ok=2 changed=0 unreachable=0 failed=0 debug ------------------------------------------------------------------- 0.10s debug mess -------------------------------------------------------------- 0.06s