On 6/18/20 1:11 PM, Nicholas Britton wrote:
> So with that option I would have two more include tasks prior where I set the 
> the next to vars?  
> 
> Any other options to keep it in one play?
> 

You could also use the product filter
(https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#product-filters):

Assign your current list to a variable, e.g asset_list and combine it with 
lists for environment and time:

with_items: "{{ asset_list | product(['prod', 'nonprod']) | product(['1800', 
'2200', '0200', '0400']) }}"

This will run over all possible combinations of the items in these three lists.

Regards
       Racke

> On Wed, Jun 17, 2020, 11:59 PM Dick Visser <[email protected] 
> <mailto:[email protected]>> wrote:
> 
>     I usually handle this by looping over  include_tasks. So each level has 
> its own file with tasks, and includes
>     another task to 'go down' one level so to speak. 
> 
> 
> 
>     On Wed, 17 Jun 2020 at 22:15, Nicholas Britton 
> <[email protected] <mailto:[email protected]>> wrote:
> 
>         I have a senerio where i think a nested with_items would work , but i 
> am not seeing any examples where there are
>         multiple keys.
> 
> 
>         Today i have a with_items that looks like this:
> 
>         |
>          - name: Include vmware workflow for Tag Setups
>             include_tasks: tasks/vmworkflow_assetgroup_create_tags_include.yml
>             with_items:
>               - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 
> 'pi', driveselect: '0', ret: '30', tagtype:
>         'Image Only', tagbg: 'bu1' }
>               - {segname: 'bu2', segabv: '2', btype: 'Image Backup', ptype: 
> 'pi', driveselect: '0', ret: '30',  tagtype:
>         'Image Only', tagbg: 'bu2' }
>               - {segname: 'bu3', segabv: '3', btype: 'Image Backup', ptype: 
> 'pi', driveselect: '0', ret: '30',  tagtype:
>         'Image Only', tagbg: 'bu3'  }
>               - {segname: 'bu1', segabv: '1', btype: 'Image with DB Backup', 
> ptype: 'pd', driveselect: '2', ret: '30',
>         tagtype: 'DB Backup', tagbg: 'bu1' }
>               - {segname: 'bu2', segabv: '2', btype: 'Image with DB Backup', 
> ptype: 'pd', driveselect: '2', ret: '30',
>         tagtype: 'DB Backup', tagbg: 'bu2' }
>               - {segname: 'bu3', segabv: '3', btype: 'Image with DB Backup', 
> ptype: 'pd', driveselect: '2', ret: '30',
>         tagtype: 'DB Backup', tagbg: 'bu3'  }
> 
>         |
> 
>         But i need to repeat each of these with two more pecies of data and 
> thought a nested would be better than
>         created 7 more of each one listed above.
> 
>         I need to device enviornment with prod or nonprod  and time with 
> 1800, 2200, 0200, 0400   
> 
>         so the included task would then have :
>         - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', 
> driveselect: '0', ret: '30', tagtype: 'Image
>         Only', tagbg: 'bu1' } prod 1800
>         - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', 
> driveselect: '0', ret: '30', tagtype: 'Image
>         Only', tagbg: 'bu1' } prod 2200
>         - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', 
> driveselect: '0', ret: '30', tagtype: 'Image
>         Only', tagbg: 'bu1' } prod 0200
>         - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', 
> driveselect: '0', ret: '30', tagtype: 'Image
>         Only', tagbg: 'bu1' } prod 0400
>         - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', 
> driveselect: '0', ret: '30', tagtype: 'Image
>         Only', tagbg: 'bu1' } nonprod 1800
>         - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', 
> driveselect: '0', ret: '30', tagtype: 'Image
>         Only', tagbg: 'bu1' } nonprod 2200
>         - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', 
> driveselect: '0', ret: '30', tagtype: 'Image
>         Only', tagbg: 'bu1' } nonprod 0200
>         - {segname: 'bu1', segabv: '1', btype: 'Image Backup', ptype: 'pi', 
> driveselect: '0', ret: '30', tagtype: 'Image
>         Only', tagbg: 'bu1' } nonprod 0400
> 
>         all as variables that i can call within the include.   Currently i am 
> calling the rest with item.segname,
>         item.segabv, etc...
> 
> 
>         thoughts or am i stuck with just having a longer list of with items?
> 
>         -- 
>         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] 
> <mailto:[email protected]>.
>         To view this discussion on the web visit
>         
> https://groups.google.com/d/msgid/ansible-project/e142aeec-a748-4d31-836c-c48bafd9e517o%40googlegroups.com
>         
> <https://groups.google.com/d/msgid/ansible-project/e142aeec-a748-4d31-836c-c48bafd9e517o%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
>     -- 
>     Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
> 
>     -- 
>     You received this message because you are subscribed to a topic in the 
> Google Groups "Ansible Project" group.
>     To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/ansible-project/fXzPHqJTLLY/unsubscribe.
>     To unsubscribe from this group and all its topics, send an email to 
> [email protected]
>     <mailto:[email protected]>.
>     To view this discussion on the web visit
>     
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwNwhaWGTUK7PexugAhRu14uy1wy975%2BmoYeyB9M7k%2BwMA%40mail.gmail.com
>     
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwNwhaWGTUK7PexugAhRu14uy1wy975%2BmoYeyB9M7k%2BwMA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAN946jRABms%2B544L0Aoc_5tZih_ghOGERj%2B5Ry4mE_jHFTfPwg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAN946jRABms%2B544L0Aoc_5tZih_ghOGERj%2B5Ry4mE_jHFTfPwg%40mail.gmail.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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/d2f75e0f-9206-3cca-dd43-c46c7da11377%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to