New in version 2.1.
Active Directory username. Use when authenticating with an Active Directory user rather than service principal.
Password for the admin username. Not required if the os_type is Linux and SSH password authentication is disabled by setting ssh_password_enabled to false.
Admin username used to access the host after it is created. Required when creating a VM.
Toggle that controls if the machine is allocated/deallocated, only useful with state='present'.
Use to control if tags field is canonical or just appends to existing tags. When canonical, any tags not found in the tags parameter will be removed from the object's metadata.
Azure client ID. Use when authenticating with a Service Principal.
A dictionary describing the Marketplace image used to build the VM. Will contain keys: publisher, offer, sku and version. NOTE: set image.version to 'latest' to get the most recent version of a given image.
Valid Azure location. Defaults to location of the resource group.
Name of the virtual machine.
List of existing network interface names to add to the VM. If a network interface name is not provided when the VM is created, a default network interface will be created. In order for the module to create a network interface, at least one Virtual Network with one Subnet must exist.
If a network interface is created when creating the VM, a security group will be created as well. For Linux hosts a rule will be added to the security group allowing inbound TCP connections to the default SSH port 22, and for Windows hosts ports 3389 and 5986 will be opened. Override the default open ports by providing a list of ports.
Type of OS disk caching.
Base type of operating system.
Active Directory user password. Use when authenticating with an Active Directory user rather than service principal.
Security profile found in ~/.azure/credentials file.
If a public IP address is created when creating the VM (because a Network Interface was not provided), determines if the public IP address remains permanently associated with the Network Interface. If set to 'Dynamic' the public IP address may change any time the VM is rebooted or power cycled.
When removing a VM using state 'absent', also remove associated resources
It can be 'all' or a list with any of the following: ['network_interfaces', 'virtual_storage', 'public_ips']
Any other input will be ignored
Name of the resource group containing the virtual machine.
Use with state 'present' to restart a running VM.
Azure client secret. Use when authenticating with a Service Principal.
Name assigned internally to the host. On a linux VM this is the name returned by the `hostname` command. When creating a virtual machine, short_hostname defaults to name.
When the os_type is Linux, setting ssh_password_enabled to false will disable SSH password authentication and require use of SSH keys.
For os_type Linux provide a list of SSH keys. Each item in the list should be a dictionary where the dictionary contains two keys: path and key_data. Set the path to the default location of the authorized_keys files. On an Enterprise Linux host, for example, the path will be /home/<admin username>/.ssh/authorized_keys. Set key_data to the actual value of the public key.
Use with state 'present' to start the machine. Set to false to have the machine be 'stopped'.
Assert the state of the virtual machine.
State 'present' will check that the machine exists with the requested configuration. If the configuration of the existing machine does not match, the machine will be updated. Use options started, allocated and restarted to change the machine's power state.
State 'absent' will remove the virtual machine.
Name of an existing storage account that supports creation of VHD blobs. If not specified for a new VM, a new storage account named <vm name>01 will be created using storage type 'Standard_LRS'.
Name fo the storage blob used to hold the VM's OS disk image. If no name is provided, defaults to the VM name + '.vhd'. If you provide a name, it must end with '.vhd'
Name of the container to use within the storage account to store VHD blobs. If no name is specified a default container will created.
When creating a virtual machine, if a network interface name is not provided, one will be created. The new network interface will be assigned to the first subnet found in the virtual network. Use this parameter to provide a specific subnet instead.
Your Azure subscription Id.
Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object will be updated with any provided values. To remove tags set append_tags option to false.
Azure tenant ID. Use when authenticating with a Service Principal.
When creating a virtual machine, if a network interface name is not provided, one will be created. The new network interface will be assigned to the first virtual network found in the resource group. Use this parameter to provide a specific virtual network instead.
A valid Azure VM size value. For example, 'Standard_D4'. The list of choices varies depending on the subscription and location. Check your subscription for available choices.
- name: Create VM with defaults azure_rm_virtualmachine: resource_group: Testing name: testvm10 admin_username: chouseknecht admin_password: <your password here> image: offer: CentOS publisher: OpenLogic sku: '7.1' version: latest - name: Create a VM with exiting storage account and NIC azure_rm_virtualmachine: resource_group: Testing name: testvm002 vm_size: Standard_D4 storage_account: testaccount001 admin_username: adminUser ssh_public_keys: - path: /home/adminUser/.ssh/authorized_keys key_data: < insert yor ssh public key here... > network_interfaces: testvm001 image: offer: CentOS publisher: OpenLogic sku: '7.1' version: latest - name: Power Off azure_rm_virtualmachine: resource_group: Testing name: testvm002 started: no - name: Deallocate azure_rm_virtualmachine: resource_group: Testing name: testvm002 allocated: no - name: Power On azure_rm_virtualmachine: resource_group: name: testvm002 - name: Restart azure_rm_virtualmachine: resource_group: name: testvm002 restarted: yes - name: remove vm and all resources except public ips azure_rm_virtualmachine: resource_group: Testing name: testvm002 state: absent remove_on_absent: - network_interfaces - virtual_storage
Common return values are documented here Return Values, the following are the fields unique to this module:
|deleted_public_ips||List of deleted public IP address names.||on delete||list|
|deleted_vhd_uris||List of deleted Virtual Hard Disk URIs.||on delete||list|
|powerstate||Indicates if the state is running, stopped, deallocated||always||string|
|deleted_network_interfaces||List of deleted NICs.||on delete||list|
|azure_vm||Facts about the current state of the object. Note that facts are not part of the registered output but available directly.||always||complex|
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
This module is supported mainly by the community and is curated by core committers.
For more information on what this means please read Module Support