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/3b4d3241-fbbd-4a77-8c12-71ccab863335%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to