I have dozens of yaml files , and I want to use these yaml files as vars in playbook. so I try to dynamic load vars like
aaa.yaml , bbb.yaml,ccc.yaml - name: get all yaml files name shell: find /home/yaml -name *.yamlawk -F "/" '{print $6}'|awk -F "." '{print $1}' register: yaml_files - name: load omdata include_vars: name: "{{ item }}" file: "/home/yaml/{{ item }}.yml" with_items: "{{ yam_files.stdout_lines }}" register: "{{ item }}" due to these 2 tasks , I should able to get many vars like aaa: { 'name': AAA , id='111' } bbb: { 'name': BBB , id='222' } with debug , I can confirm those vars are been loaded. - name: debug yaml_files debug: var: "{{ item }}" with_items: "{{ yaml_files.stdout_lines }}" and now , how could I get the vaule in those var files ? I try to do so by - name: create yaml_file shell: echo "{{ item }}.name"|tee -a /tmp/tmp.txt with_items: "{{ yaml_files.stdout_lines }}" I though "{{ item }}.name" will get aaa.name which is AAA but instead , I get "aaa.name" in tmp.txt any suggestions will be appreciated , thanks ! -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d9fd2b5f-d144-4136-8f6a-692d37960602%40googlegroups.com.