# Give a module an ansible group?

**URL:** <https://forum.ansible.com/t/give-a-module-an-ansible-group/13827>\
**Category:** Ansible Project\
**Created:** [November 1, 2013, 10:31pm UTC](https://forum.ansible.com/t/give-a-module-an-ansible-group/13827 "2013-11-01T22:31:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curtis](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Curtis](https://forum.ansible.com/u/Curtis)\
**Post date:** [November 1, 2013, 10:31pm UTC](https://forum.ansible.com/t/give-a-module-an-ansible-group/13827/1 "2013-11-01T22:31:22Z")

</div>

Hi All,

I would like something to happen on a server based on another group. Well I think that’s what I want. 🙂

ie. run the below on the proxy node:

- name: let the proxy node know about the storage nodes  
some\_custom\_module: nodes=group[‘storage’] othervar=something

Then in the module I would iterate over the group and do something on the proxy with information about each storage node.

Is that possible or the right way to do it?

Would love to hear if this is just plain wrong or if there is a better way.

Thanks,  
Curtis.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 2, 2013, 2:55am UTC](https://forum.ansible.com/t/give-a-module-an-ansible-group/13827/2 "2013-11-02T02:55:18Z")

</div>

If I understand what you want to do, I think you mean this:

- shell: /usr/bin/foo --some-parameter {{ inventory\_hostname }} # this is what you are looping over in the host loop  
delegate\_to: “{{ item }}”  
with\_items: groups.other\_group # you are sending the command to every machine in this group

---

<div class="post-metadata">

**Author:** ![Curtis](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Curtis](https://forum.ansible.com/u/Curtis)\
**Post date:** [November 3, 2013, 3:42pm UTC](https://forum.ansible.com/t/give-a-module-an-ansible-group/13827/3 "2013-11-03T15:42:38Z")

</div>

> If I understand what you want to do, I think you mean this:
> 
> - shell: /usr/bin/foo --some-parameter {{ inventory\_hostname }} # this is  
> what you are looping over in the host loop  
> &nbsp;&nbsp;&nbsp;delegate\_to: "{{ item }}"  
> &nbsp;&nbsp;&nbsp;with\_items: groups.other\_group # you are sending the command to every  
> machine in this group

I knew there must be a way to do this. I think delegate\_to will work. Much  
appreciated!

Thanks,  
Curtis.
