Give a module an ansible group?

Hi All,

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

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.

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

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

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

Thanks,
Curtis.