# ansible to create multiple security groups with os\_security\_group module

**URL:** <https://forum.ansible.com/t/ansible-to-create-multiple-security-groups-with-os-security-group-module/32430>\
**Category:** Ansible Project\
**Created:** [March 10, 2020, 3:03pm UTC](https://forum.ansible.com/t/ansible-to-create-multiple-security-groups-with-os-security-group-module/32430 "2020-03-10T15:03:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert2](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@Robert2](https://forum.ansible.com/u/Robert2)\
**Post date:** [March 10, 2020, 3:03pm UTC](https://forum.ansible.com/t/ansible-to-create-multiple-security-groups-with-os-security-group-module/32430/1 "2020-03-10T15:03:35Z")

</div>

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](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
