# with\_dict and with\_items together in ansible task

**URL:** <https://forum.ansible.com/t/with-dict-and-with-items-together-in-ansible-task/23170>\
**Category:** Ansible Project\
**Created:** [December 5, 2016, 11:34am UTC](https://forum.ansible.com/t/with-dict-and-with-items-together-in-ansible-task/23170 "2016-12-05T11:34:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepa\_Yr](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@Deepa\_Yr](https://forum.ansible.com/u/Deepa_Yr)\
**Post date:** [December 5, 2016, 11:34am UTC](https://forum.ansible.com/t/with-dict-and-with-items-together-in-ansible-task/23170/1 "2016-12-05T11:34:38Z")

</div>

Hi

My requirement is to install multiple patches on different machines based on which all tiers the patch is supported for install. Say patch1 should be installed on client group and service group, patch2 should be installed on client group and database group machines.

- name: Install patch on services tier  
include: roles/common/tasks/install\_patch\_services.yml  
when: ({{item.value.services\_repo}} == True)  
with\_dict: “{{patches\_dict}}”  
delegate\_to: “{{ groups.is\_services[0] }}”

Here I am using dict to traverse through all patches and install on different groups.  
If there are multiple hosts in a group, how can I write a task? It should consider patch1 install on services[0], services[1] and patch2 on services[0],services[1] and so on…

Please provide your inputs how it can be achieved ?
