azure.azcollection.azure_rm_virtualmachinescaleset module – Manage Azure virtual machine scale sets
Note
This module is part of the azure.azcollection collection (version 1.19.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install azure.azcollection
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: azure.azcollection.azure_rm_virtualmachinescaleset
.
New in azure.azcollection 0.1.2
Synopsis
Create and update a virtual machine scale set.
Note that this module was called azure.azcollection.azure_rm_virtualmachine_scaleset before Ansible 2.8. The usage did not change.
Requirements
The below requirements are needed on the host that executes this module.
python >= 2.7
The host that executes this module must have the azure.azcollection collection installed via galaxy
All python packages listed in collection’s requirements-azure.txt must be installed via pip on the host that executes modules from azure.azcollection
Full installation instructions may be found https://galaxy.ansible.com/azure/azcollection
Parameters
Parameter |
Comments |
---|---|
Active Directory username. Use when authenticating with an Active Directory user rather than service principal. |
|
Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority. |
|
Password for the admin username. Not required if the os_type is Linux and SSH password authentication is disabled by setting ssh_password_enabled=false. |
|
Admin username used to access the host after it is created. Required when creating a VM. |
|
Selects an API profile to use when communicating with Azure services. Default value of Default: |
|
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. Choices:
|
|
Application gateway name. |
|
Controls the source of the credentials to use for authentication. Can also be set via the When set to When set to When set to When set to When set to The Choices:
|
|
Capacity of VMSS. Default: |
|
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 Choices:
|
|
Azure client ID. Use when authenticating with a Service Principal. |
|
For cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, Default: |
|
Data which is made available to the virtual machine and used by e.g., Many images in the marketplace are not cloud-init ready. Thus, data sent to custom_data would be ignored. If the image you are attempting to use is not listed in https://docs.microsoft.com/en-us/azure/virtual-machines/linux/using-cloud-init#cloud-init-overview, follow these steps https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cloudinit-prepare-custom-image. |
|
Describes list of data disks. |
|
Type of data disk caching. Choices:
|
|
The initial disk size in GB for blank data disks. |
|
The logical unit number for data disk. Default: |
|
Managed data disk type. Choices:
|
|
Indicates whether user wants to allow accelerated networking for virtual machines in scaleset being created. Choices:
|
|
Parameters of ephemeral disk settings that can be specified for operating system disk. Ephemeral OS disk is only supported for VMS Instances using Managed Disk. Choices:
|
|
Specifies the eviction policy for the Azure Spot virtual machine. Requires priority to be set to Spot. Choices:
|
|
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 that set version=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 that 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. Required when creating. |
|
Load balancer name. |
|
Valid Azure location. Defaults to location of the resource group. |
|
Parent argument. |
|
Parent argument. |
|
Managed disk type. Choices:
|
|
Specifies the maximum price you are willing to pay for a Azure Spot VM/VMSS. This price is in US Dollars.
Requires priority to be set to Spot. Default: |
|
Name of the virtual machine. |
|
Specifies the orchestration mode for the virtual machine scale set. When orchestration_mode=Flexible, public_ip_per_vm=True must be set. When orchestration_mode=Flexible, platform_fault_domain_count must be set. When orchestration_mode=Flexible, single_placement_group=False must be set. When orchestration_mode=Flexible, it cannot be configured overprovision. When orchestration_mode=Flexible, it cannot be configured upgrade_policy and configured when orchestration_mode=Uniform. Choices:
|
|
Type of OS disk caching. Choices:
|
|
Specifies the size of the operating system disk in gigabytes. This can be used to overwrite the size of the disk in a virtual machine image. |
|
Base type of operating system. Choices:
|
|
Specifies whether the Virtual Machine Scale Set should be overprovisioned. Choices:
|
|
Active Directory user password. Use when authenticating with an Active Directory user rather than service principal. |
|
Third-party billing plan for the VM. |
|
Billing plan name. |
|
Product name. |
|
Optional promotion code. |
|
Publisher offering the plan. |
|
Fault Domain count for each placement group. Default: |
|
Priority of the VMSS.
Choices:
|
|
Security profile found in ~/.azure/credentials file. |
|
Assign a public IP to each virtual machine of the scale set Choices:
|
|
When removing a VM using state=absent, also remove associated resources. It can be Any other input will be ignored. Default: |
|
Name of the resource group containing the virtual machine scale set. |
|
define the order in which vmss instances are scaled-in Choices:
|
|
Azure client secret. Use when authenticating with a Service Principal. |
|
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. |
|
Specifies the Security related profile settings for the virtual machine sclaset. |
|
This property can be used by user in the request to enable or disable the Host Encryption for the virtual machine sclaset. This will enable the encryption for all the disks including Resource/Temp disk at host itself. Choices:
|
|
Specifies the SecurityType of the virtual machine sclaset. It is set as TrustedLaunch to enable UefiSettings. Choices:
|
|
Specifies the security settings like secure boot and vTPM used while creating the virtual machine scalset. |
|
Specifies whether secure boot should be enabled on the virtual machine sclaset. Choices:
|
|
Specifies whether vTPM should be enabled on the virtual machine scalset. Choices:
|
|
Short host name. |
|
When true this limits the scale set to a single placement group, of max size 100 virtual machines. Choices:
|
|
When the os_type is Linux, setting ssh_password_enabled=false will disable SSH password authentication and require use of SSH keys. Choices:
|
|
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, Set the On an Enterprise Linux host, for example, the path=/home/<admin username>/.ssh/authorized_keys. Set |
|
Assert the state of the virtual machine scale set. State State Choices:
|
|
Subnet name. |
|
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. Currently, Azure DNS zones and Traffic Manager services also don’t allow the use of spaces in the tag. Azure Front Door doesn’t support the use of Azure Automation and Azure CDN only support 15 tags on resources. |
|
Azure tenant ID. Use when authenticating with a Service Principal. |
|
timeout time for termination notification event in range between 5 and 15 |
|
The thumbprint of the private key specified in x509_certificate_path. Use when authenticating with a Service Principal. Required if x509_certificate_path is defined. |
|
SKU Tier. Choices:
|
|
Upgrade policy. Required when creating the Azure virtual machine scale sets. Choices:
|
|
Virtual Network name. |
|
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. |
|
A valid Azure VM size value. For example, The list of choices varies depending on the subscription and location. Check your subscription for available choices. |
|
Path to the X509 certificate used to create the service principal in PEM format. The certificate must be appended to the private key. Use when authenticating with a Service Principal. |
|
A list of Availability Zones for your virtual machine scale set. |
Notes
Note
For authentication with Azure you can pass parameters, set environment variables, use a profile stored in ~/.azure/credentials, or log in before you run your tasks or playbook with
az login
.Authentication is also 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.
See Also
See also
- Sign in with Azure CLI
How to authenticate using the
az login
command.
Examples
- name: Create VMSS
azure_rm_virtualmachinescaleset:
resource_group: myResourceGroup
name: testvmss
vm_size: Standard_DS1_v2
capacity: 2
virtual_network_name: testvnet
upgrade_policy: Manual
subnet_name: testsubnet
terminate_event_timeout_minutes: 10
scale_in_policy: NewestVM
admin_username: "{{ username }}"
ssh_password_enabled: false
ssh_public_keys:
- path: /home/adminUser/.ssh/authorized_keys
key_data: < insert your ssh public key here... >
managed_disk_type: Standard_LRS
image:
offer: 0001-com-ubuntu-server-focal
publisher: canonical
sku: 20_04-lts-gen2
version: latest
data_disks:
- lun: 0
disk_size_gb: 64
caching: ReadWrite
managed_disk_type: Standard_LRS
- name: Create VMSS with an image that requires plan information
azure_rm_virtualmachinescaleset:
resource_group: myResourceGroup
name: testvmss
vm_size: Standard_DS1_v2
capacity: 3
virtual_network_name: testvnet
upgrade_policy: Manual
subnet_name: testsubnet
admin_username: "{{ username }}"
ssh_password_enabled: false
ssh_public_keys:
- path: /home/adminUser/.ssh/authorized_keys
key_data: < insert your ssh public key here... >
managed_disk_type: Standard_LRS
image:
offer: cis-ubuntu-linux-1804-l1
publisher: center-for-internet-security-inc
sku: Stable
version: latest
plan:
name: cis-ubuntu-linux-1804-l1
product: cis-ubuntu-linux-1804-l1
publisher: center-for-internet-security-inc
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_virtualmachinescaleset:
resource_group: myResourceGroup
name: testvmss
vm_size: Standard_DS1_v2
capacity: 2
virtual_network_name: testvnet
upgrade_policy: Manual
subnet_name: testsubnet
admin_username: "{{ username }}"
admin_password: "{{ password }}"
managed_disk_type: Standard_LRS
image: customimage001
- name: Create a VMSS with over 100 instances
azure_rm_virtualmachinescaleset:
resource_group: myResourceGroup
name: testvmss
vm_size: Standard_DS1_v2
capacity: 120
single_placement_group: false
virtual_network_name: testvnet
upgrade_policy: Manual
subnet_name: testsubnet
admin_username: "{{ username }}"
admin_password: "{{ password }}"
managed_disk_type: Standard_LRS
image: customimage001
- name: Create a VMSS with a custom image from a particular resource group
azure_rm_virtualmachinescaleset:
resource_group: myResourceGroup
name: testvmss
vm_size: Standard_DS1_v2
capacity: 2
virtual_network_name: testvnet
upgrade_policy: Manual
subnet_name: testsubnet
admin_username: "{{ username }}"
admin_password: "{{ password }}"
managed_disk_type: Standard_LRS
image:
name: customimage001
resource_group: myResourceGroup
- name: Create a VMSS with Spot Instance
azure_rm_virtualmachinescaleset:
resource_group: myResourceGroup
name: testvmss
vm_size: Standard_DS1_v2
capacity: 5
priority: Spot
eviction_policy: Deallocate
virtual_network_name: testvnet
upgrade_policy: Manual
subnet_name: testsubnet
admin_username: "{{ username }}"
admin_password: "{{ password }}"
managed_disk_type: Standard_LRS
image: customimage001
- name: Create VMSS with security group
azure_rm_virtualmachinescaleset:
resource_group: "{{ resource_group }}"
name: testVMSS{{ rpfx }}
vm_size: Standard_D4s_v3
admin_username: testuser
single_placement_group: false
platform_fault_domain_count: 1
public_ip_per_vm: true
ssh_password_enabled: false
ssh_public_keys:
- path: /home/testuser/.ssh/authorized_keys
key_data: "ssh-rsa ****"
virtual_network_name: VMSStestVnet
subnet_name: VMSStestSubnet
managed_disk_type: Standard_LRS
orchestration_mode: Flexible
os_disk_caching: ReadWrite
security_profile:
uefi_settings:
secure_boot_enabled: true
v_tpm_enabled: false
encryption_at_host: false
security_type: TrustedLaunch
image:
offer: 0001-com-ubuntu-server-jammy
publisher: Canonical
sku: 22_04-lts-gen2
version: latest
data_disks:
- lun: 0
disk_size_gb: 64
caching: ReadWrite
managed_disk_type: Standard_LRS
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Facts about the current state of the object. Note that facts are not part of the registered output but available directly. Returned: always Sample: |