# Error Creating Azure Security Group

**URL:** <https://forum.ansible.com/t/error-creating-azure-security-group/21909>\
**Category:** Ansible Project\
**Tags:** azure\
**Created:** [July 1, 2016, 9:39pm UTC](https://forum.ansible.com/t/error-creating-azure-security-group/21909 "2016-07-01T21:39:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Carter](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@Steven\_Carter](https://forum.ansible.com/u/Steven_Carter)\
**Post date:** [July 1, 2016, 9:39pm UTC](https://forum.ansible.com/t/error-creating-azure-security-group/21909/1 "2016-07-01T21:39:14Z")

</div>

When I do the following in my playbook:

- name: Create CSR Security Group  
azure\_rm\_securitygroup:  
resource\_group: ‘{{ resource\_group }}’  
name: csr\_security\_group  
purge\_rules: yes  
rules:
- name: AllowSSH  
protocol: Tcp  
destination\_port\_range: 22  
access: Allow  
priority: 100  
direction: Inbound

I get the error:

TASK [Create CSR Security Group] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/stevenca/ansible/azure/mk\_azure\_csr\_node.yml:42  
\<127.0.0.1\> ESTABLISH LOCAL CONNECTION FOR USER: stevenca  
\<127.0.0.1\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1467408964.56-63206774886516`” && echo ansible-tmp-1467408964.56-63206774886516=“`echo $HOME/.ansible/tmp/ansible-tmp-1467408964.56-63206774886516`” ) && sleep 0’  
\<127.0.0.1\> PUT /tmp/tmp0GW2R7 TO /home/stevenca/.ansible/tmp/ansible-tmp-1467408964.56-63206774886516/azure\_rm\_securitygroup  
\<127.0.0.1\> EXEC /bin/sh -c ‘LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /home/stevenca/.ansible/tmp/ansible-tmp-1467408964.56-63206774886516/azure\_rm\_securitygroup; rm -rf “/home/stevenca/.ansible/tmp/ansible-tmp-1467408964.56-63206774886516/” \> /dev/null 2\>&1 && sleep 0’  
An exception occurred during task execution. The full traceback is:  
Traceback (most recent call last):  
File “/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py”, line 715, in   
main()  
File “/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py”, line 712, in main  
AzureRMSecurityGroup()  
File “/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py”, line 539, in **init**  
supports\_check\_mode=True)  
File “/tmp/ansible\_Bv3FoN/ansible\_modlib.zip/ansible/module\_utils/azure\_rm\_common.py”, line 173, in **init**  
File “/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py”, line 573, in exec\_module  
results = create\_network\_security\_group\_dict(nsg)  
File “/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py”, line 488, in create\_network\_security\_group\_dict  
results[‘rules’].append(create\_rule\_dict\_from\_obj(rule))  
File “/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py”, line 464, in create\_rule\_dict\_from\_obj  
protocol=rule.protocol.value,  
AttributeError: ‘unicode’ object has no attribute ‘value’

fatal: [localhost]: FAILED! =\> {“changed”: false, “failed”: true, “invocation”: {“module\_name”: “azure\_rm\_securitygroup”}, “module\_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py", line 715, in \n main()\n File "/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py", line 712, in main\n AzureRMSecurityGroup()\n File "/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py", line 539, in **init** \n supports\_check\_mode=True)\n File "/tmp/ansible\_Bv3FoN/ansible\_modlib.zip/ansible/module\_utils/azure\_rm\_common.py", line 173, in **init** \n File "/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py", line 573, in exec\_module\n results = create\_network\_security\_group\_dict(nsg)\n File "/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py", line 488, in create\_network\_security\_group\_dict\n results[‘rules’].append(create\_rule\_dict\_from\_obj(rule))\n File "/tmp/ansible\_Bv3FoN/ansible\_module\_azure\_rm\_securitygroup.py", line 464, in create\_rule\_dict\_from\_obj\n protocol=rule.protocol.value,\nAttributeError: ‘unicode’ object has no attribute ‘value’\n”, “module\_stdout”: “”, “msg”: “MODULE FAILURE”, “parsed”: false}

At this point, I am running ansible 2.1.1.0 with azure python modules 2.0.0rc5. I was able to create a resource group, vnet, and 2 x subnets, then got stuck here.

Thanks,

Steven.

---

<div class="post-metadata">

**Author:** ![Steven\_Carter](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@Steven\_Carter](https://forum.ansible.com/u/Steven_Carter)\
**Post date:** [July 1, 2016, 9:41pm UTC](https://forum.ansible.com/t/error-creating-azure-security-group/21909/2 "2016-07-01T21:41:11Z")

</div>

I forgot to mention that it actually creates the security group, it just has a problem with the return. I had a similar behavior when trying to create nics.

Steven.

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [July 5, 2016, 11:46pm UTC](https://forum.ansible.com/t/error-creating-azure-security-group/21909/3 "2016-07-05T23:46:56Z")

</div>

Yep, twas another shape change in the Python SDK- they flattened a bunch of SDK values somewhere in there (where you used to have to dot into a “value” member).

Should be fixed in 2.1.1RC2 and devel by [https://github.com/ansible/ansible-modules-core/commit/de9959b129d927bc3a7c8022da1c7d84747763b8](https://github.com/ansible/ansible-modules-core/commit/de9959b129d927bc3a7c8022da1c7d84747763b8).
