provisioning azure VMs with azure module

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

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
  gather_facts: false
  tasks:

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 ********************************************************************

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

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

that seems to be an error with the azure python library

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.

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.

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.

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