# provisioning azure VMs with azure module

**URL:** <https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210>\
**Category:** Ansible Project\
**Tags:** azure\
**Created:** [January 7, 2015, 8:12pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210 "2015-01-07T20:12:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Liu](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@Jeff\_Liu](https://forum.ansible.com/u/Jeff_Liu)\
**Post date:** [January 7, 2015, 8:12pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210/1 "2015-01-07T20:12:55Z")

</div>

Hi All,

Ansible: 1.8.2  
Python-azure: 0.9.0

I’m trying to use ansible to provision an Azure VM, but I’m getting the following error:

$ ansible-playbook test.yml  
ERROR: local\_action is not a legal parameter at this level in an Ansible Playbook

$ cat test.yml

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 7, 2015, 8:25pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210/2 "2015-01-07T20:25:10Z")

</div>

test.yml is not a valid playbook, it only lists tasks, you need a play.

try adding this to the top and indenting the rest to be under 'tasks:'

- hosts: localhost  
&nbsp;&nbsp;gather\_facts: false  
&nbsp;&nbsp;tasks:

---

<div class="post-metadata">

**Author:** ![Jeff\_Liu](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@Jeff\_Liu](https://forum.ansible.com/u/Jeff_Liu)\
**Post date:** [January 7, 2015, 8:50pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210/3 "2015-01-07T20:50:16Z")

</div>

Silly me. Yes, that gets me farther.  
Thank you.

Now it seems to be failing on checking if the name is available - looks like a management cert error.  
I’ll have to continue debugging…

TASK: [create test instance] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [localhost → 127.0.0.1] =\> {“failed”: true, “parsed”: false}  
Traceback (most recent call last):  
File “/home/jklee/.ansible/tmp/ansible-tmp-1420663748.48-67769107595964/azure”, line 2049, in   
main()  
File “/home/jklee/.ansible/tmp/ansible-tmp-1420663748.48-67769107595964/azure”, line 445, in main  
(changed, public\_dns\_name, deployment) = create\_virtual\_machine(module, azure)  
File “/home/jklee/.ansible/tmp/ansible-tmp-1420663748.48-67769107595964/azure”, line 249, in create\_virtual\_machine  
cloud\_service\_name\_available = azure.check\_hosted\_service\_name\_availability(name)  
File “/usr/lib/python2.6/site-packages/azure/servicemanagement/servicemanagementservice.py”, line 811, in check\_hosted\_service\_name\_availability  
AvailabilityResponse)  
File “/usr/lib/python2.6/site-packages/azure/servicemanagement/servicemanagementclient.py”, line 218, in \_perform\_get  
response = self.perform\_get(path, x\_ms\_version)  
File “/usr/lib/python2.6/site-packages/azure/servicemanagement/servicemanagementclient.py”, line 114, in perform\_get  
response = self.\_perform\_request(request)  
File “/usr/lib/python2.6/site-packages/azure/servicemanagement/servicemanagementclient.py”, line 190, in \_perform\_request  
resp = self.\_filter(request)  
File “/usr/lib/python2.6/site-packages/azure/http/httpclient.py”, line 205, in perform\_request  
self.send\_request\_headers(connection, request.headers)  
File “/usr/lib/python2.6/site-packages/azure/http/httpclient.py”, line 184, in send\_request\_headers  
connection.endheaders()  
File “/usr/lib64/python2.6/httplib.py”, line 908, in endheaders  
self.\_send\_output()  
File “/usr/lib64/python2.6/httplib.py”, line 780, in \_send\_output  
self.send(msg)  
File “/usr/lib64/python2.6/httplib.py”, line 739, in send  
self.connect()  
File “/usr/lib64/python2.6/httplib.py”, line 1116, in connect  
self.sock = ssl.wrap\_socket(sock, self.key\_file, self.cert\_file)  
File “/usr/lib64/python2.6/ssl.py”, line 342, in wrap\_socket  
suppress\_ragged\_eofs=suppress\_ragged\_eofs)  
File “/usr/lib64/python2.6/ssl.py”, line 118, in **init**  
cert\_reqs, ssl\_version, ca\_certs)  
ssl.SSLError: [Errno 336265225] \_ssl.c:341: error:140B0009:SSL routines:SSL\_CTX\_use\_PrivateKey\_file:PEM lib

FATAL: all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

---

<div class="post-metadata">

**Author:** ![Jeff\_Liu](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@Jeff\_Liu](https://forum.ansible.com/u/Jeff_Liu)\
**Post date:** [January 7, 2015, 8:53pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210/4 "2015-01-07T20:53:32Z")

</div>

Okay, looks like I’m getting the same error as reported here:

[https://github.com/ansible/ansible-modules-core/issues/397](https://github.com/ansible/ansible-modules-core/issues/397)

No attribute ‘public\_ips’

$ ansible-playbook -i hosts azure.yml

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [create test instance] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [localhost → 127.0.0.1] =\> {“failed”: true, “parsed”: false}  
Traceback (most recent call last):  
File “/home/jklee/.ansible/tmp/ansible-tmp-1420663902.48-135102767689358/azure”, line 2049, in   
main()  
File “/home/jklee/.ansible/tmp/ansible-tmp-1420663902.48-135102767689358/azure”, line 445, in main  
(changed, public\_dns\_name, deployment) = create\_virtual\_machine(module, azure)  
File “/home/jklee/.ansible/tmp/ansible-tmp-1420663902.48-135102767689358/azure”, line 309, in create\_virtual\_machine  
virtual\_network\_name=virtual\_network\_name)  
File “/usr/lib/python2.6/site-packages/azure/servicemanagement/servicemanagementservice.py”, line 1259, in create\_virtual\_machine\_deployment  
reserved\_ip\_name),  
File “/usr/lib/python2.6/site-packages/azure/servicemanagement/ **init**.py”, line 2392, in virtual\_machine\_deployment\_to\_xml  
media\_location)  
File “/usr/lib/python2.6/site-packages/azure/servicemanagement/ **init**.py”, line 2230, in role\_to\_xml  
network\_configuration\_set)  
File “/usr/lib/python2.6/site-packages/azure/servicemanagement/ **init**.py”, line 2193, in network\_configuration\_to\_xml  
if configuration.public\_ips:  
AttributeError: ‘ConfigurationSetInputEndpoints’ object has no attribute ‘public\_ips’

FATAL: all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/home/jklee/azure.retry

localhost : ok=0 changed=0 unreachable=0 failed=1

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 7, 2015, 9:04pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210/5 "2015-01-07T21:04:04Z")

</div>

that seems to be an error with the azure python library

---

<div class="post-metadata">

**Author:** ![Jeff\_Liu](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@Jeff\_Liu](https://forum.ansible.com/u/Jeff_Liu)\
**Post date:** [January 7, 2015, 9:05pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210/6 "2015-01-07T21:05:57Z")

</div>

In Azure, there’s a concept of a cloud service (sort of a container that is created first) that is associated with one or more VM instances, and in fact that is created by the ansible play. So it looks like the Azure API has changed where it expects additional information regarding the VM.

---

<div class="post-metadata">

**Author:** ![Jeff\_Liu](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@Jeff\_Liu](https://forum.ansible.com/u/Jeff_Liu)\
**Post date:** [January 8, 2015, 4:38pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210/7 "2015-01-08T16:38:15Z")

</div>

Just an FYI, it seems that downgrading the python azure library to v0.8.4 fixes the issue.  
I’ll put a note into the github issue below as well.

---

<div class="post-metadata">

**Author:** ![Jeff\_Liu](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@Jeff\_Liu](https://forum.ansible.com/u/Jeff_Liu)\
**Post date:** [January 8, 2015, 6:59pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210/8 "2015-01-08T18:59:28Z")

</div>

Another follow up, downgrading to v0.8.4 seems to allow the creation of a linux VM, but it does not properly terminate.  
The Linux VM is deleted, but the associated cloud service is not deleted.

---

<div class="post-metadata">

**Author:** ![Jeff\_Liu](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@Jeff\_Liu](https://forum.ansible.com/u/Jeff_Liu)\
**Post date:** [January 8, 2015, 7:16pm UTC](https://forum.ansible.com/t/provisioning-azure-vms-with-azure-module/17210/9 "2015-01-08T19:16:59Z")

</div>

As well as the disk associated with the Linux VM is not deleted.
