Thank you for your reply. The objective is to compile a list of variables from files in a directory without using the merge behaviour. In my example I use with_items but it should be with_fileglob
var1.yml myvar: "example1" var2.yml myvar: "example2" var3.yml myvar: "example3" compiled_list: - myvar: "example1" - myvar: "example2" - myvar: "example3" Since the templating does not happen facts any more. And I dont have the option to enable merge behaviour. Any other alternative ? On Monday, February 8, 2016 at 10:15:03 AM UTC+1, DomaNitro wrote: > > For the last month I have been trying convert my v1 action plugin to v2 > with no luck. > https://groups.google.com/forum/#!topic/ansible-devel/9-i8uIj9E5g > > So Brian suggested to use default include_vars with a loop. So decided to > try to use ansible built in modules. but the same issue came up that I had > in my custom module. > > test.yml > --- > - name: Test include_vars template > hosts: all > connection: local > gather_facts: False > vars: > common_var: "my var is defined" > tasks: > - name: Debug common_var > debug: var=common_var > - name: Include var1.yml > include_vars: "{{ item }}" > with_items: > - "var1.yml" > register: foo_result > - name: Debug results > debug: > var=foo_result.results > - name: Compile a list > set_fact: > compiled_list="{{ foo_result.results | > map(attribute='ansible_facts') | list }}" > - name: debug compile list > debug: var=compiled_list > > var1.yml > --- > var1: > mysyste: "1" > my_var: "{{ common_var }}" > > > to run > >> ansible-playbook -i 127.0.0.1, test.yml >> > > > > The results > TASK [Debug common_var] > ******************************************************** > ok: [127.0.0.1] => { > "common_var": "my var is defined" > } > TASK [Debug results] > *********************************************************** > ok: [127.0.0.1] => { > "foo_result.results": [ > { > "_ansible_no_log": false, > "ansible_facts": { > "var1": { > "my_var": "{# common_var #}", > "mysyste": "1" > } > }, > "invocation": { > "module_args": { > "_raw_params": "var1.yml" > }, > "module_name": "include_vars" > }, > "item": "var1.yml" > } > ] > } > > TASK [debug compile list] > ok: [127.0.0.1] => { > "compiled_list": [ > { > "var1": { > "my_var": "{# common_var #}", > "mysyste": "1" > } > } > ] > } > > Ansible fails to substitute variable in V2. the above code works with V1, > So second level substitution does not work. The variable appears as a > Jinja2 comment"{# common_var #}" instead of "my var is defined" > > Regards > > > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/cfdd43d4-0993-4447-b9e2-00a5da333f89%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
