Your question can be interpreted at least two ways.
Here are two answers, one of which may be what you're looking for.

        ---
        - name: Combining lists
          hosts: localhost
          gather_facts: false
        
          vars:
            cluster_data: ['cluster1','cluster2']
            aggr_data: ['aggr1','aggr2',]
        
          tasks:
            - name: Combine with zip
              ansible.builtin.debug:
                msg: "zip: {{ ','.join(item) }}"
              loop: "{{ cluster_data | zip(aggr_data) }}"
        
            - name: Combine with product
              ansible.builtin.debug:
                msg: "product: {{ ','.join(item) }}"
              loop: "{{ cluster_data | product(aggr_data) }}"

The output from the above playbook looks like this:

        PLAY [Combining lists] *****************************
        
        TASK [Combine with zip] ****************************
        ok: [localhost] => (item=['cluster1', 'aggr1']) => {
            "msg": "zip: cluster1,aggr1"
        }
        ok: [localhost] => (item=['cluster2', 'aggr2']) => {
            "msg": "zip: cluster2,aggr2"
        }
        
        TASK [Combine with product] ************************
        ok: [localhost] => (item=['cluster1', 'aggr1']) => {
            "msg": "product: cluster1,aggr1"
        }
        ok: [localhost] => (item=['cluster1', 'aggr2']) => {
            "msg": "product: cluster1,aggr2"
        }
        ok: [localhost] => (item=['cluster2', 'aggr1']) => {
            "msg": "product: cluster2,aggr1"
        }
        ok: [localhost] => (item=['cluster2', 'aggr2']) => {
            "msg": "product: cluster2,aggr2"
        }


On 3/3/23 1:25 PM, Aharonu wrote:
Hi Team,

Could anyone please help on below query? Thank you.

I have 2 registered variables data as example below. How to call those data over the loop?
/
/
/Vars:/
/Cluster_data:  ['cluster1','cluster2']/
/Aggr_data:  ['aggr1','aggr2',]/
/ Tasks:/
/ - name: calling var data/
/   <module_name>:/
///cluster: ??<item>//    --> here, I need to use 'Cluster_data' list/
///aggregate: ??<item> //--> here, I need to use 'Aggr_data' list/
///loop: ??/
//
Once again, thank you for your help.


--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a59790e5-8bfb-f683-01a1-6ab911101917%40gmail.com.

Reply via email to