azure_rm_virtualmachine_scaleset – Manage Azure virtual machine scale sets.

New in version 2.4.

Synopsis

  • Create and update a virtual machine scale set.

Requirements

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

  • python >= 2.7
  • azure >= 2.0.0

Parameters

Parameter Choices/Defaults Comments
ad_user
-
Active Directory username. Use when authenticating with an Active Directory user rather than service principal.
adfs_authority_url
-
added in 2.6
Default:
null
Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority.
admin_password
-
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
-
Admin username used to access the host after it is created. Required when creating a VM.
api_profile
-
added in 2.5
Default:
"latest"
Selects an API profile to use when communicating with Azure services. Default value of latest is appropriate for public clouds; future values will allow use with Azure Stack.
append_tags
boolean
    Choices:
  • no
  • yes ←
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.
auth_source
-
added in 2.5
    Choices:
  • auto
  • cli
  • credential_file
  • env
  • msi
Controls the source of the credentials to use for authentication.
If not specified, ANSIBLE_AZURE_AUTH_SOURCE environment variable will be used and default to auto if variable is not defined.
auto will follow the default precedence of module parameters -> environment variables -> default profile in credential file ~/.azure/credentials.
When set to cli, the credentials will be sources from the default Azure CLI profile.
Can also be set via the ANSIBLE_AZURE_AUTH_SOURCE environment variable.
When set to msi, the host machine must be an azure resource with an enabled MSI extension. subscription_id or the environment variable AZURE_SUBSCRIPTION_ID can be used to identify the subscription ID if the resource is granted access to more than one subscription, otherwise the first subscription is chosen.
The msi was added in Ansible 2.6.
capacity
- / required
Default:
1
Capacity of VMSS.
cert_validation_mode
-
added in 2.5
    Choices:
  • validate
  • ignore
Controls the certificate validation behavior for Azure endpoints. By default, all modules will validate the server certificate, but when an HTTPS proxy is in use, or against Azure Stack, it may be necessary to disable this behavior by passing ignore. Can also be set via credential file profile or the AZURE_CERT_VALIDATION environment variable.
client_id
-
Azure client ID. Use when authenticating with a Service Principal.
cloud_environment
-
added in 2.4
Default:
"AzureCloud"
For cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, AzureChinaCloud, AzureUSGovernment), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or the AZURE_CLOUD_ENVIRONMENT environment variable.
data_disks
-
added in 2.4
Describes list of data disks.
caching
-
added in 2.4
    Choices:
  • ReadOnly ←
  • ReadWrite
Type of data disk caching.
disk_size_gb
-
added in 2.4
The initial disk size in GB for blank data disks.
lun
-
added in 2.4
Default:
0
The logical unit number for data disk.
managed_disk_type
-
added in 2.4
    Choices:
  • Standard_LRS
  • Premium_LRS
Managed data disk type.
enable_accelerated_networking
boolean
added in 2.7
    Choices:
  • no
  • yes
Indicates whether user wants to allow accelerated networking for virtual machines in scaleset being created.
image
- / required
Specifies the image used to build the VM.
If a string, the image is sourced from a custom image based on the name.
If a dict with the keys publisher, offer, sku, and version, the image is sourced from a Marketplace image. NOTE: set image.version to latest to get the most recent version of a given image.
If a dict with the keys name and resource_group, the image is sourced from a custom image based on the name and resource_group set. NOTE: the key resource_group is optional and if omitted, all images in the subscription will be searched for by name.
Custom image support was added in Ansible 2.5
load_balancer
-
added in 2.5
Load balancer name.
location
-
Valid Azure location. Defaults to location of the resource group.
managed_disk_type
-
    Choices:
  • Standard_LRS
  • Premium_LRS
Managed disk type.
name
- / required
Name of the virtual machine.
os_disk_caching
-
    Choices:
  • ReadOnly ←
  • ReadWrite
Type of OS disk caching.

aliases: disk_caching
os_type
-
    Choices:
  • Windows
  • Linux ←
Base type of operating system.
password
-
Active Directory user password. Use when authenticating with an Active Directory user rather than service principal.
profile
-
Security profile found in ~/.azure/credentials file.
remove_on_absent
-
Default:
["all"]
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.
resource_group
- / required
Name of the resource group containing the virtual machine scale set.
secret
-
Azure client secret. Use when authenticating with a Service Principal.
security_group
-
added in 2.7
Existing security group with which to associate the subnet.
It can be the security group name which is in the same resource group.
It can be the resource Id.
It can be a dict which contains name and resource_group of the security group.

aliases: security_group_name
short_hostname
-
Short host name
ssh_password_enabled
boolean
    Choices:
  • no
  • yes ←
When the os_type is Linux, setting ssh_password_enabled to false will disable SSH password authentication and require use of SSH keys.
ssh_public_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.
state
-
    Choices:
  • absent
  • present ←
Assert the state of the virtual machine scale set.
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. state.
State 'absent' will remove the virtual machine scale set.
subnet_name
-
Subnet name.

aliases: subnet
subscription_id
-
Your Azure subscription Id.
tags
-
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.
tenant
-
Azure tenant ID. Use when authenticating with a Service Principal.
tier
-
    Choices:
  • Basic
  • Standard
SKU Tier.
upgrade_policy
-
    Choices:
  • Manual
  • Automatic
Upgrade policy.
virtual_network_name
-
Virtual Network name.

aliases: virtual_network
virtual_network_resource_group
-
added in 2.5
When creating a virtual machine, if a specific virtual network from another resource group should be used, use this parameter to specify the resource group to use.
vm_size
- / required
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.

Notes

Note

  • For authentication with Azure you can pass parameters, set environment variables or use a profile stored in ~/.azure/credentials. Authentication is possible using a service principal or Active Directory user. To authenticate via service principal, pass subscription_id, client_id, secret and tenant or set environment variables AZURE_SUBSCRIPTION_ID, AZURE_CLIENT_ID, AZURE_SECRET and AZURE_TENANT.
  • To authenticate via Active Directory user, pass ad_user and password, or set AZURE_AD_USER and AZURE_PASSWORD in the environment.
  • Alternatively, credentials can be stored in ~/.azure/credentials. This is an ini file containing a [default] section and the following keys: subscription_id, client_id, secret and tenant or subscription_id, ad_user and password. It is also possible to add additional profiles. Specify the profile by passing profile or setting AZURE_PROFILE in the environment.

Examples

- name: Create VMSS
  azure_rm_virtualmachine_scaleset:
    resource_group: Testing
    name: testvmss
    vm_size: Standard_DS1_v2
    capacity: 2
    virtual_network_name: testvnet
    subnet_name: testsubnet
    admin_username: adminUser
    ssh_password_enabled: false
    ssh_public_keys:
      - path: /home/adminUser/.ssh/authorized_keys
        key_data: < insert yor ssh public key here... >
    managed_disk_type: Standard_LRS
    image:
      offer: CoreOS
      publisher: CoreOS
      sku: Stable
      version: latest
    data_disks:
      - lun: 0
        disk_size_gb: 64
        caching: ReadWrite
        managed_disk_type: Standard_LRS

- name: Create a VMSS with a custom image
  azure_rm_virtualmachine_scaleset:
    resource_group: Testing
    name: testvmss
    vm_size: Standard_DS1_v2
    capacity: 2
    virtual_network_name: testvnet
    subnet_name: testsubnet
    admin_username: adminUser
    admin_password: password01
    managed_disk_type: Standard_LRS
    image: customimage001

- name: Create a VMSS with a custom image from a particular resource group
  azure_rm_virtualmachine_scaleset:
    resource_group: Testing
    name: testvmss
    vm_size: Standard_DS1_v2
    capacity: 2
    virtual_network_name: testvnet
    subnet_name: testsubnet
    admin_username: adminUser
    admin_password: password01
    managed_disk_type: Standard_LRS
    image:
      name: customimage001
      resource_group: Testing

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
azure_vmss
complex
always
Facts about the current state of the object. Note that facts are not part of the registered output but available directly.

  properties
-

  sku
-

  tags
-

  type
-



Status

Authors

  • Sertac Ozercan (@sozercan)

Hint

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