ansible to create multiple security groups with os_security_group module

Hey everyone,

Has anyone been successful in using the openstack module os_security_group to create a list of security groups? Here is what I have:


- hosts: localhost
gather_facts: no
vars_prompt:
- name: username
prompt: “What is your username?”
private: no

- name: password
prompt: “What is your password?”

tasks:
- name: Security Group Creation
os_security_group:
auth:
username: “{{ username }}”
password: “{{ password }}”
project_name: “project-a”
auth_url: “https://auth-url.local:13000//v3
user_domain_name: “domain-X”
project_domain_name: “domain-Y”
state: present

name: “{{ item }}”
loop:
- sg-default
- sg-kafka

What ends up happening is I get one security group that looks like this: [‘sg-default’,‘sg-kafka’]

I am using ansible 2.8.6

Any help or guidance is appreciated.

–Robert