azure – create or terminate a virtual machine in azure

New in version 1.7.

DEPRECATED

Removed in Ansible:
 version: 2.8
Why:Replaced with various dedicated Azure modules.
Alternative:azure_rm_virtualmachine

Synopsis

  • Creates or terminates azure instances. When created optionally waits for it to be ‘running’.

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 2.6
  • azure >= 0.7.1

Parameters

Parameter Choices/Defaults Comments
auto_updates
boolean
added in 2.0
    Choices:
  • no ←
  • yes
Enable Auto Updates on Windows Machines
enable_winrm
boolean
added in 2.0
    Choices:
  • no
  • yes ←
Enable winrm on Windows Machines
endpoints
-
Default:
22
a comma-separated list of TCP ports to expose on the virtual machine (e.g., "22,80")
hostname
-
hostname to write /etc/hostname. Defaults to <name>.cloudapp.net.
image
- / required
system image for creating the virtual machine (e.g., b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-precise-12_04_3-LTS-amd64-server-20131205-en-us-30GB)
location
- / required
the azure location to use (e.g. 'East US')
management_cert_path
-
path to an azure management certificate associated with the subscription id. Overrides the AZURE_CERT_PATH environment variable.
name
- / required
name of the virtual machine and associated cloud service.
os_type
-
added in 2.0
    Choices:
  • windows
  • linux ←
The type of the os that is gettings provisioned
password
-
the unix password for the new virtual machine.
role_size
-
Default:
"Small"
azure role size for the new virtual machine (e.g., Small, ExtraLarge, A6). You have to pay attention to the fact that instances of type G and DS are not available in all regions (locations). Make sure if you selected the size and type of instance available in your chosen location.
ssh_cert_path
-
path to an X509 certificate containing the public ssh key to install in the virtual machine. See http://www.windowsazure.com/en-us/manage/linux/tutorials/intro-to-linux/ for more details.
if this option is specified, password-based ssh authentication will be disabled.
state
-
    Choices:
  • absent
  • present ←
create or terminate instances
storage_account
- / required
the azure storage account in which to store the data disks.
subscription_id
-
azure subscription id. Overrides the AZURE_SUBSCRIPTION_ID environment variable.
user
-
the unix username for the new virtual machine.
virtual_network_name
-
Name of virtual network.
wait
boolean
    Choices:
  • no ←
  • yes
wait for the instance to be in state 'running' before returning
wait_timeout
-
Default:
600
how long before wait gives up, in seconds
wait_timeout_redirects
-
Default:
300
how long before wait gives up for redirects, in seconds

Examples

# Note: None of these examples set subscription_id or management_cert_path
# It is assumed that their matching environment variables are set.

- name: Provision virtual machine example
  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: True
    state: present
  delegate_to: localhost

- name: Terminate virtual machine example
  azure:
    name: my-virtual-machine
    state: absent
  delegate_to: localhost

- name: Create windows machine
  azure:
    name: ben-Winows-23
    hostname: win123
    os_type: windows
    enable_winrm: True
    subscription_id: '{{ azure_sub_id }}'
    management_cert_path: '{{ azure_cert_path }}'
    role_size: Small
    image: bd507d3a70934695bc2128e3e5a255ba__RightImage-Windows-2012-x64-v13.5
    location: East Asia
    password: xxx
    storage_account: benooytes
    user: admin
    wait: True
    state: present
    virtual_network_name: '{{ vnet_name }}'
  delegate_to: localhost

Status

  • This module will be removed in version 2.8. [deprecated]
  • For more information see DEPRECATED.

Authors

  • John Whitbeck (@jwhitbeck)

Hint

If you notice any issues in this documentation you can edit this document to improve it.