provisioning azure VMs with azure module

329 views
Skip to first unread message

Jeffrey Liu

unread,
Jan 7, 2015, 3:12:55 PM1/7/15
to ansible...@googlegroups.com

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
---
# Provision virtual machine example
 - local_action:
     module: azure
     name: my-virtual-machine
     role_size: Small
     image: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-precise-12_04_3-LTS-amd64-server-20131205-en-us-30GB
     location: 'East US'
     user: ubuntu
     ssh_cert_path: /path/to/azure_x509_cert.pem
     storage_account: my-storage-account
     wait: yes


Not sure if I'm doing something wrong?

Thanks,
Jeff


Brian Coca

unread,
Jan 7, 2015, 3:25:14 PM1/7/15
to ansible...@googlegroups.com
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:


--
Brian Coca

Jeffrey Liu

unread,
Jan 7, 2015, 3:50:16 PM1/7/15
to ansible...@googlegroups.com
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 <module>
    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 ********************************************************************

Jeffrey Liu

unread,
Jan 7, 2015, 3:53:32 PM1/7/15
to ansible...@googlegroups.com
Okay, looks like I'm getting the same error as reported here:


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

Brian Coca

unread,
Jan 7, 2015, 4:04:08 PM1/7/15
to ansible...@googlegroups.com
that seems to be an error with the azure python library


--
Brian Coca

Jeffrey Liu

unread,
Jan 7, 2015, 4:05:57 PM1/7/15
to ansible...@googlegroups.com
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.

Jeffrey Liu

unread,
Jan 8, 2015, 11:38:15 AM1/8/15
to ansible...@googlegroups.com
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.

Jeffrey Liu

unread,
Jan 8, 2015, 1:59:28 PM1/8/15
to ansible...@googlegroups.com
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.

Jeffrey Liu

unread,
Jan 8, 2015, 2:16:59 PM1/8/15
to ansible...@googlegroups.com
As well as the disk associated with the Linux VM is not deleted.
Reply all
Reply to author
Forward
0 new messages