azure / azure.azcollection / 2.3.0 / module / azure_rm_virtualmachinescaleset Manage Azure virtual machine scale sets | "added in version" 0.1.2 of azure.azcollection" Authors: Sertac Ozercan (@sozercan)azure.azcollection.azure_rm_virtualmachinescaleset (2.3.0) — module
Install with ansible-galaxy collection install azure.azcollection:==2.3.0
collections: - name: azure.azcollection version: 2.3.0
Create and update a virtual machine scale set.
Note that this module was called M(azure.azcollection.azure_rm_virtualmachine_scaleset) before Ansible 2.8. The usage did not change.
- 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
name: description: - Name of the virtual machine. required: true type: str plan: description: - Third-party billing plan for the VM. suboptions: name: description: - Billing plan name. required: true type: str product: description: - Product name. required: true type: str promotion_code: description: - Optional promotion code. type: str publisher: description: - Publisher offering the plan. required: true type: str type: dict tags: description: - 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. type: dict tier: choices: - Basic - Standard description: - SKU Tier. type: str image: description: - 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 I(publisher), I(offer), I(sku), and I(version), the image is sourced from a Marketplace image. Note that set I(version=latest) to get the most recent version of a given image. - If a dict with the keys I(name) and I(resource_group), the image is sourced from a custom image based on the I(name) and I(resource_group) set. Note that the key I(resource_group) is optional and if omitted, all images in the subscription will be searched for by I(name). - Custom image support was added in Ansible 2.5. - Required when creating. type: raw state: choices: - absent - present default: present description: - Assert the state of the virtual machine scale set. - State C(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 C(absent) will remove the virtual machine scale set. type: str zones: description: - A list of Availability Zones for your virtual machine scale set. elements: str type: list secret: description: - Azure client secret. Use when authenticating with a Service Principal. type: str tenant: description: - Azure tenant ID. Use when authenticating with a Service Principal. type: str ad_user: description: - Active Directory username. Use when authenticating with an Active Directory user rather than service principal. type: str os_type: choices: - Windows - Linux default: Linux description: - Base type of operating system. type: str profile: description: - Security profile found in ~/.azure/credentials file. type: str vm_size: description: - A valid Azure VM size value. For example, C(Standard_D4). - The list of choices varies depending on the subscription and location. Check your subscription for available choices. type: str capacity: default: 1 description: - Capacity of VMSS. type: int location: description: - Valid Azure location. Defaults to location of the resource group. type: str log_mode: description: - Parent argument. type: str log_path: description: - Parent argument. type: str password: description: - Active Directory user password. Use when authenticating with an Active Directory user rather than service principal. type: str priority: choices: - None - Spot description: - Priority of the VMSS. - C(None) is the equivalent of Regular VM. type: str client_id: description: - Azure client ID. Use when authenticating with a Service Principal or Managed Identity (msi). - Can also be set via the C(AZURE_CLIENT_ID) environment variable. type: str max_price: default: -1 description: - Specifies the maximum price you are willing to pay for a Azure Spot VM/VMSS. - This price is in US Dollars. - C(-1) indicates default price to be up-to on-demand. - Requires priority to be set to Spot. type: float data_disks: description: - Describes list of data disks. elements: dict suboptions: caching: choices: - ReadOnly - ReadWrite default: ReadOnly description: - Type of data disk caching. type: str disk_size_gb: description: - The initial disk size in GB for blank data disks. type: int lun: default: '0' description: - The logical unit number for data disk. type: str managed_disk_type: choices: - Standard_LRS - Premium_LRS - StandardSSD_LRS - UltraSSD_LRS - Premium_ZRS - StandardSSD_ZRS description: - Managed data disk type. type: str type: list thumbprint: description: - The thumbprint of the private key specified in I(x509_certificate_path). - Use when authenticating with a Service Principal. - Required if I(x509_certificate_path) is defined. type: str version_added: 1.14.0 version_added_collection: azure.azcollection api_profile: default: latest description: - Selects an API profile to use when communicating with Azure services. Default value of C(latest) is appropriate for public clouds; future values will allow use with Azure Stack. type: str version_added: 0.0.1 version_added_collection: azure.azcollection append_tags: default: true description: - 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. type: bool auth_source: choices: - auto - cli - credential_file - env - msi default: auto description: - Controls the source of the credentials to use for authentication. - Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable. - When set to C(auto) (the default) the precedence is module parameters -> C(env) -> C(credential_file) -> C(cli). - When set to C(env), the credentials will be read from the environment variables - When set to C(credential_file), it will read the profile from C(~/.azure/credentials). - When set to C(cli), the credentials will be sources from the Azure CLI profile. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if more than one is present otherwise the default az cli subscription is used. - When set to C(msi), the host machine must be an azure resource with an enabled MSI extension. C(subscription_id) or the environment variable C(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 C(msi) was added in Ansible 2.6. type: str version_added: 0.0.1 version_added_collection: azure.azcollection custom_data: description: - Data which is made available to the virtual machine and used by e.g., C(cloud-init). - Many images in the marketplace are not cloud-init ready. Thus, data sent to I(custom_data) would be ignored. - If the image you are attempting to use is not listed in U(https://docs.microsoft.com/en-us/azure/virtual-machines/linux/using-cloud-init#cloud-init-overview), follow these steps U(https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cloudinit-prepare-custom-image). type: str subnet_name: aliases: - subnet description: - Subnet name. type: str load_balancer: description: - Load balancer name. type: str overprovision: description: - Specifies whether the Virtual Machine Scale Set should be overprovisioned. type: bool admin_password: description: - Password for the admin username. - Not required if the os_type is Linux and SSH password authentication is disabled by setting I(ssh_password_enabled=false). type: str admin_username: description: - Admin username used to access the host after it is created. Required when creating a VM. type: str resource_group: description: - Name of the resource group containing the virtual machine scale set. required: true type: str security_group: aliases: - security_group_name description: - 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 I(name) and I(resource_group) of the security group. type: raw short_hostname: description: - Short host name. type: str upgrade_policy: choices: - Manual - Automatic description: - Upgrade policy. - Required when creating the Azure virtual machine scale sets. type: str eviction_policy: choices: - Deallocate - Delete description: - Specifies the eviction policy for the Azure Spot virtual machine. - Requires priority to be set to Spot. type: str os_disk_caching: aliases: - disk_caching choices: - ReadOnly - ReadWrite default: ReadOnly description: - Type of OS disk caching. type: str os_disk_size_gb: description: - 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. type: int scale_in_policy: choices: - Default - NewestVM - OldestVM description: - define the order in which vmss instances are scaled-in type: str ssh_public_keys: description: - For I(os_type=Linux) provide a list of SSH keys. - Each item in the list should be a dictionary where the dictionary contains two keys, C(path) and C(key_data). - Set the C(path) to the default location of the authorized_keys files. - On an Enterprise Linux host, for example, the I(path=/home/<admin username>/.ssh/authorized_keys). Set C(key_data) to the actual value of the public key. elements: dict type: list subscription_id: description: - Your Azure subscription Id. type: str public_ip_per_vm: default: false description: - Assign a public IP to each virtual machine of the scale set type: bool remove_on_absent: default: - all description: - When removing a VM using I(state=absent), also remove associated resources. - It can be C(all) or a list with any of the following ['network_interfaces', 'virtual_storage', 'public_ips']. - Any other input will be ignored. elements: str type: list security_profile: description: - Specifies the Security related profile settings for the virtual machine sclaset. suboptions: encryption_at_host: description: - 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. type: bool security_type: choices: - TrustedLaunch description: - Specifies the SecurityType of the virtual machine sclaset. - It is set as TrustedLaunch to enable UefiSettings. type: str uefi_settings: description: - Specifies the security settings like secure boot and vTPM used while creating the virtual machine scalset. suboptions: secure_boot_enabled: description: - Specifies whether secure boot should be enabled on the virtual machine sclaset. type: bool v_tpm_enabled: description: - Specifies whether vTPM should be enabled on the virtual machine scalset. type: bool type: dict type: dict cloud_environment: default: AzureCloud description: - For cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, C(AzureChinaCloud), C(AzureUSGovernment)), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or the C(AZURE_CLOUD_ENVIRONMENT) environment variable. type: str version_added: 0.0.1 version_added_collection: azure.azcollection ephemeral_os_disk: description: - 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. type: bool managed_disk_type: choices: - Standard_LRS - Premium_LRS - StandardSSD_LRS - UltraSSD_LRS - Premium_ZRS - StandardSSD_ZRS description: - Managed disk type. type: str adfs_authority_url: description: - Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority. type: str version_added: 0.0.1 version_added_collection: azure.azcollection orchestration_mode: choices: - Flexible - Uniform default: Flexible description: - Specifies the orchestration mode for the virtual machine scale set. - When I(orchestration_mode=Flexible), I(public_ip_per_vm=True) must be set. - When I(orchestration_mode=Flexible), I(platform_fault_domain_count) must be set. - When I(orchestration_mode=Flexible), I(single_placement_group=False) must be set. - When I(orchestration_mode=Flexible), it cannot be configured I(overprovision). - When I(orchestration_mode=Flexible), it cannot be configured I(upgrade_policy) and configured when I(orchestration_mode=Uniform). type: str application_gateway: description: - Application gateway name. type: str cert_validation_mode: choices: - ignore - validate description: - 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 C(ignore). Can also be set via credential file profile or the C(AZURE_CERT_VALIDATION) environment variable. type: str version_added: 0.0.1 version_added_collection: azure.azcollection ssh_password_enabled: default: true description: - When the os_type is Linux, setting I(ssh_password_enabled=false) will disable SSH password authentication and require use of SSH keys. type: bool virtual_network_name: aliases: - virtual_network description: - Virtual Network name. type: str x509_certificate_path: description: - 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. type: path version_added: 1.14.0 version_added_collection: azure.azcollection single_placement_group: default: false description: - When true this limits the scale set to a single placement group, of max size 100 virtual machines. type: bool disable_instance_discovery: default: false description: - Determines whether or not instance discovery is performed when attempting to authenticate. Setting this to true will completely disable both instance discovery and authority validation. This functionality is intended for use in scenarios where the metadata endpoint cannot be reached such as in private clouds or Azure Stack. The process of instance discovery entails retrieving authority metadata from https://login.microsoft.com/ to validate the authority. By setting this to **True**, the validation of the authority is disabled. As a result, it is crucial to ensure that the configured authority host is valid and trustworthy. - Set via credential file profile or the C(AZURE_DISABLE_INSTANCE_DISCOVERY) environment variable. type: bool version_added: 2.3.0 version_added_collection: azure.azcollection platform_fault_domain_count: default: 1 description: - Fault Domain count for each placement group. type: int enable_accelerated_networking: description: - Indicates whether user wants to allow accelerated networking for virtual machines in scaleset being created. type: bool virtual_network_resource_group: description: - 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. type: str terminate_event_timeout_minutes: description: - timeout time for termination notification event - in range between 5 and 15 type: int
azure_vmss: 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: properties: orchestrationMode: Flexible overprovision: true platformFaultDomainCount: 1 scaleInPolicy: rules: - NewestVM singlePlacementGroup: true upgradePolicy: mode: Manual virtualMachineProfile: networkProfile: networkInterfaceConfigurations: - name: testvmss properties: dnsSettings: dnsServers: [] enableAcceleratedNetworking: false ipConfigurations: - name: default properties: privateIPAddressVersion: IPv4 subnet: id: /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/myResourceGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet primary: true osProfile: adminUsername: testuser computerNamePrefix: testvmss linuxConfiguration: disablePasswordAuthentication: true ssh: publicKeys: - keyData: '' path: /home/testuser/.ssh/authorized_keys secrets: [] scheduledEventsProfile: terminateNotificationProfile: enable: true notBeforeTimeout: PT10M storageProfile: dataDisks: - caching: ReadWrite createOption: empty diskSizeGB: 64 lun: 0 managedDisk: storageAccountType: Standard_LRS imageReference: offer: 0001-com-ubuntu-server-focal publisher: canonical sku: 20_04-lts-gen2 version: 20.04.202111210 osDisk: caching: ReadWrite createOption: fromImage managedDisk: storageAccountType: Standard_LRS securityProfile: encryptionAtHost: false securityType: TrustedLaunch uefiSettings: secureBootEnabled: true vTpmEnabled: false sku: capacity: 2 name: Standard_DS1_v2 tier: Standard tags: null type: Microsoft.Compute/virtualMachineScaleSets type: dict