is it possible to add multiple security group rules to a security group using os_security_group & os_security_group_rule?

Hi Folks,

I am wondering if it is possible to add multiple rules to an openstack security group using a loop mechanism such as with_items or with_dict?

I gave found examples of where this is possible in AWS using somthing like

security_groups:

  • name: http_access
    rules:
  • proto: tcp
    from_port: 80
    to_port: 80
    cidr_ip: 0.0.0.0/0
  • proto: tcp
    from_port: 22
    to_port: 22
    cidr_ip: 0.0.0.0/0
    rules_egress:

tasks:

  • name: add security groups.
    ec2_group:
    name: “{{ item.name }}”
    description: add security group rules
    region: “{{ item.region }}”
    state: present
    rules: “{{ item.rules }}”
    rules_egress: “{{ item.rules_egress }}”
    with_items: security_groups

I have tried various configurations to try and achieve the same outcome using os_security_group and os_security_group_rule but cannot manage to get more than a single rule attached to any one security group.

Thanks in advance for your time.

Cheers,
Glyn