I'm trying to set multiple security groups at once using the ansible cloud stack module. The yaml file currently looks like this:
- name: add inbound tcp rules to security group web
cs_securitygroup_rule:
security_group: web
start_port: "{{ item }}"
end_port: "{{ item }}"
loop:
- 80
- 443
The problem is there could be a vast number of security groups. So this code block would repeat over and over again, which seems not like a good solution. So I'd like to turn this whole thing into one single loop and pass the arguments using dictionaries. The datastructure cloud look something like this:
cs_security_groups:
web:
- 80
- 443
monitor:
- 9090
- 9100
- 9333
default:
- 22
I simply can't get this to work using any kind of loop because a security group could have an arbitrary number of ports. Am I missing something or is this approach completely wrong?