Hi John Buxton,

thanks for your reply.
Indeed that worked.

--
- name: combine lists
  hosts: localhost
  vars:
    - level1keyA:
        - hostname: foo
          state: present
          path:
            - left
        - hostname: bar
          state: present
          path:
            - righthere
            - "{{ ['righthere'] |union (level1keyB) }}"
    - level1keyB:
      - right
      - middle
      - top
  tasks:
    - name: result of level1keyA
      debug:
        msg: "{{ level1keyA }}"

    - name: result of level1keyB
      debug:
        msg: "{{ level1keyB }}"



:~/ansible ansible-playbook test.yml                                       
                                                                            
                                                                 

PLAY [combine lists] 
***********************************************************

TASK [setup] 
*******************************************************************
Friday 01 April 2016  08:47:45 +0200 (0:00:00.016)       0:00:00.017 
********** 
ok: [localhost]

TASK [result of level1keyA] 
****************************************************
Friday 01 April 2016  08:47:46 +0200 (0:00:00.599)       0:00:00.616 
********** 
ok: [localhost] => {
    "msg": [
        {
            "hostname": "foo", 
            "path": [
                "left"
            ], 
            "state": "present"
        }, 
        {
            "hostname": "bar", 
            "path": [
                "righthere", 
                [
                    "righthere", 
                    "right", 
                    "middle", 
                    "top"
                ]
            ], 
            "state": "present"
        }
    ]
}

TASK [result of level1keyB] 
****************************************************
Friday 01 April 2016  08:47:46 +0200 (0:00:00.030)       0:00:00.646 
********** 
ok: [localhost] => {
    "msg": [
        "right", 
        "middle", 
        "top"
    ]
}

PLAY RECAP 
*********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0


But would it be possible to do this also with multiple entries in path of 
level1keyA? Like:

---
- name: combine lists
  hosts: localhost
  vars:
    - level1keyA:
        - hostname: foo
          state: present
          path:
            - left
        - hostname: bar
          state: present
          path:
            - righthere
            - peter
            - paul
            - mary
            - "{{ WHAT NOW HERE? |union (level1keyB) }}"
    - level1keyB:
      - right
      - middle
      - top
  tasks:
    - name: result of level1keyA
      debug:
        msg: "{{ level1keyA }}"

    - name: result of level1keyB
      debug:
        msg: "{{ level1keyB }}"

Listing all peter, paul, mary etc in front of the union wouldn't be very 
convenient either.

Thank you

Jard

-- 
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/72be1d79-2c54-4e01-a6f1-60e399dc2b98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to