I figure out this problem, but now I stuck with implementation....
This is playbook
---
- name: Demo of with_nested
  hosts: host1
  vars:
     FS_LIST:
        member1:
          FS: "/tmp/f1/dev"
          config_files: ["config1.xml","config2.xml"]
        member2:
          FS: "/tmp/f2/dev"
          config_files: ["config1.xml"]
  tasks:
    - name: Printing message
      debug: msg=" {% for i in item.config_files %} Values are {{item.FS}} 
and {{i}}\n{% endfor %} "
      with_items:
        - "{{FS_LIST.values()}}"

and it prints mi all permutation as I wish
            "msg": "  Values are /tmp/f1/dev and config1.xml\n Values are 
/tmp/f1/dev and config2.xml\n "
            "msg": "  Values are /tmp/f2/dev and config1.xml\n "


So i tried to implement this logic to template:
This template is just to check syntax:
---
- name: Demo of with_nested
  hosts: host1
  vars:
     FS_LIST:
        member1:
          FS: "/tmp/f1/dev"
          config_files: ["config1.xml","config2.xml"]
        member2:
          FS: "/tmp/f2/dev"
          config_files: ["config1.xml"]
  tasks:
    - name: Printing message
      template: src=/tmp/config1.xml.j2 dest={{item.FS}}/config1.xml
      with_items:
        - "{{FS_LIST.values()}}"

*BUT*
When i tried to do this:
---
- name: Demo of with_nested
  hosts: nestor71.vestigo.hr
  remote_user: vu00338
  vars:
     FS_LIST:
        member1:
          FS: "/tmp/f1/dev"
          config_files: ["config1.xml","config2.xml"]
        member2:
          FS: "/tmp/f2/dev"
          config_files: ["config1.xml"]
  tasks:
    - name: Printing message
*      template: {% for i in item.config_files %} src={{i}}.j2 
dest={{item.FS}}/{{i}} {% endfor %}*
      with_items:
        - "{{FS_LIST.values()}}"


I got error:
The offending line appears to be:

    - name: Printing message
      template: {% for i in item.config_files %} src={{i}}.j2 
dest={{item.FS}}/{{i}} {% endfor %}
                 ^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes.  Always quote template expression brackets when they
start a value. For instance:

    with_items:
      - {{ foo }}

Should be written as:

    with_items:
      - "{{ foo }}"


Any idea...thanks a lot...





-- 
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/58a3beea-f5d6-4a8e-aa7b-6bd1f190f824%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to