Documentation

azure - create or terminate a virtual machine in azure

New in version 1.7.

Synopsis

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

Requirements (on host that executes module)

  • python >= 2.6
  • azure >= 0.7.1

Options

parameter required default choices comments
auto_updates
(added in 2.0)
no no
  • yes
  • no
Enable Auto Updates on Windows Machines
enable_winrm
(added in 2.0)
no yes
  • yes
  • no
Enable winrm on Windows Machines
endpoints
no 22
a comma-separated list of TCP ports to expose on the virtual machine (e.g., "22,80")
hostname
no
hostname to write /etc/hostname. Defaults to <name>.cloudapp.net.
image
yes
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
yes
the azure location to use (e.g. 'East US')
management_cert_path
no
path to an azure management certificate associated with the subscription id. Overrides the AZURE_CERT_PATH environment variable.
name
yes
name of the virtual machine and associated cloud service.
os_type
(added in 2.0)
no linux
  • windows
  • linux
The type of the os that is gettings provisioned
password
no
the unix password for the new virtual machine.
role_size
no 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
no
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
no present
create or terminate instances
storage_account
yes
the azure storage account in which to store the data disks.
subscription_id
no
azure subscription id. Overrides the AZURE_SUBSCRIPTION_ID environment variable.
user
no
the unix username for the new virtual machine.
virtual_network_name
no
Name of virtual network.
wait
no no
  • yes
  • no
wait for the instance to be in state 'running' before returning
wait_timeout
no 600
how long before wait gives up, in seconds
wait_timeout_redirects
no 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 is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Support

This module is community maintained without core committer oversight.

For more information on what this means please read Module Support

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.