Deprecated

Removed in 2.8

i

Reason:Replaced with various dedicated Azure modules. | Alternative:M(azure_rm_virtualmachine)

ansible.builtin._azure (v2.7.18) — module

create or terminate a virtual machine in azure

| "added in version" 1.7 of ansible.builtin"

Authors: John Whitbeck (@jwhitbeck)

deprecated | supported by community

Install Ansible via pip

Install with pip install ansible==2.7.18

Description

Creates or terminates azure instances. When created optionally waits for it to be 'running'.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Terminate virtual machine example
  azure:
    name: my-virtual-machine
    state: absent
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
name:
    description:
    - name of the virtual machine and associated cloud service.
    required: true

user:
    description:
    - the unix username for the new virtual machine.

wait:
    default: 'no'
    description:
    - wait for the instance to be in state 'running' before returning
    type: bool

image:
    description:
    - system image for creating the virtual machine (e.g., b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-precise-12_04_3-LTS-amd64-server-20131205-en-us-30GB)
    required: true

state:
    choices:
    - absent
    - present
    default: present
    description:
    - create or terminate instances

os_type:
    choices:
    - windows
    - linux
    default: linux
    description:
    - The type of the os that is gettings provisioned
    version_added: '2.0'
    version_added_collection: ansible.builtin

hostname:
    description:
    - hostname to write /etc/hostname. Defaults to <name>.cloudapp.net.

location:
    description:
    - the azure location to use (e.g. 'East US')
    required: true

password:
    description:
    - the unix password for the new virtual machine.

endpoints:
    default: 22
    description:
    - a comma-separated list of TCP ports to expose on the virtual machine (e.g., "22,80")

role_size:
    default: Small
    description:
    - 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.

auto_updates:
    default: 'no'
    description:
    - Enable Auto Updates on Windows Machines
    type: bool
    version_added: '2.0'
    version_added_collection: ansible.builtin

enable_winrm:
    default: 'yes'
    description:
    - Enable winrm on Windows Machines
    type: bool
    version_added: '2.0'
    version_added_collection: ansible.builtin

wait_timeout:
    default: 600
    description:
    - how long before wait gives up, in seconds

ssh_cert_path:
    description:
    - 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.

storage_account:
    description:
    - the azure storage account in which to store the data disks.
    required: true

subscription_id:
    description:
    - azure subscription id. Overrides the AZURE_SUBSCRIPTION_ID environment variable.

management_cert_path:
    description:
    - path to an azure management certificate associated with the subscription id. Overrides
      the AZURE_CERT_PATH environment variable.

virtual_network_name:
    description:
    - Name of virtual network.

wait_timeout_redirects:
    default: 300
    description:
    - how long before wait gives up for redirects, in seconds