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]>
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].
> 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 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/CAL8fbwNwhaWGTUK7PexugAhRu14uy1wy975%2BmoYeyB9M7k%2BwMA%40mail.gmail.com.

Reply via email to