ec2_group with a rule opening a port to other nodes of the same group

I need to define an EC2 security group that opens a port to other nodes of the same group. The use case is Elastic Search cluster autodiscovery. Which looks legitimate enough to me :slight_smile:

As far as I can tell, there is no way to do it with the current implementation of ec2_group module. I could pretty easily write a one-liner patch for that module so that group_id: self (or some other magic word) makes it so. Is that a good way to do this?

–Alex

I’ve faced this, with an elasticsearch sg being one of my requirements (in my setup I’d have to make a directed acylic graph of the security groups in order to have them all created in a single run).

Resorted to a playbook with two plays, one that creates my security groups (no rules), tagged create, and another that populates them, tagged configure (or whatever you like).

`

Just after posting here I found this post in the group. It does what I want. All I need to do is make sure I add group_desc with group_name everywhere. And then I can just do a single play, with rules in the calls to ec2_group.

:smiley: #happy