community / community.azure / 0.1.0 / module / azure_rm_virtualmachine_scaleset Manage Azure virtual machine scale sets Authors: Sertac Ozercan (@sozercan) preview | supported by communitycommunity.azure.azure_rm_virtualmachine_scaleset (0.1.0) — module
Install with ansible-galaxy collection install community.azure:==0.1.0
collections: - name: community.azure version: 0.1.0
Create and update a virtual machine scale set.
Note that this module was called M(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: 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 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: 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: 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: adminUser admin_password: password01 managed_disk_type: Standard_LRS image: customimage001
- name: Create a VMSS with a custom image and override data disk 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: adminUser admin_password: password01 managed_disk_type: Standard_LRS image: customimage001 data_disks: - lun: 0 disk_size_gb: 64 caching: ReadWrite managed_disk_type: Standard_LRS create_option: FromImage
- 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: 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_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: adminUser admin_password: password01 managed_disk_type: Standard_LRS image: name: customimage001 resource_group: myResourceGroup
name: description: - Name of the virtual machine. required: true plan: description: - Third-party billing plan for the VM. suboptions: name: description: - Billing plan name. required: true product: description: - Product name. required: true promotion_code: description: - Optional promotion code. publisher: description: - Publisher offering the plan. required: true 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. type: dict tier: choices: - Basic - Standard description: - SKU Tier. 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: true 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. zones: description: - A list of Availability Zones for your virtual machine scale set. 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. 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. capacity: default: 1 description: - Capacity of VMSS. location: description: - Valid Azure location. Defaults to location of the resource group. password: description: - Active Directory user password. Use when authenticating with an Active Directory user rather than service principal. type: str priority: choices: - Regular - Low default: Regular description: - If you want to request low-priority VMs for the VMSS, set this to "Low". The default is "Regular" client_id: description: - Azure client ID. Use when authenticating with a Service Principal. type: str data_disks: description: - Describes list of data disks. suboptions: caching: choices: - ReadOnly - ReadWrite default: ReadOnly description: - Type of data disk caching. create_option: choices: - Empty - FromImage description: - Specify whether disk should be created Empty or FromImage. This is required to allow custom images with data disks to be used. disk_size_gb: description: - The initial disk size in GB for blank data disks. lun: default: 0 description: - The logical unit number for data disk. managed_disk_type: choices: - Standard_LRS - Premium_LRS description: - Managed data disk type. 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: '2.5' 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 description: - 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 C(auto) if variable is not defined. - C(auto) will follow the default precedence of module parameters -> environment variables -> default profile in credential file C(~/.azure/credentials). - When set to C(cli), the credentials will be sources from the default Azure CLI profile. - Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable. - 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: '2.5' 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). subnet_name: aliases: - subnet description: - Subnet name. load_balancer: description: - Load balancer name. overprovision: default: true 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). admin_username: description: - Admin username used to access the host after it is created. Required when creating a VM. resource_group: description: - Name of the resource group containing the virtual machine scale set. required: true 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. short_hostname: description: - Short host name. upgrade_policy: choices: - Manual - Automatic description: - Upgrade policy. - Required when creating the Azure virtual machine scale sets. os_disk_caching: aliases: - disk_caching choices: - ReadOnly - ReadWrite default: ReadOnly description: - Type of OS disk caching. scale_in_policy: choices: - Default - NewestVM - OldestVM description: - define the order in which vmss instances are scaled-in 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. subscription_id: description: - Your Azure subscription Id. type: str 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. 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: '2.4' version_added_collection: azure.azcollection managed_disk_type: choices: - Standard_LRS - Premium_LRS description: - Managed disk type. adfs_authority_url: description: - Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority. type: str version_added: '2.6' version_added_collection: azure.azcollection application_gateway: description: - Application gateway name. 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: '2.5' 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. single_placement_group: default: true description: - When true this limits the scale set to a single placement group, of max size 100 virtual machines. type: bool 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. terminate_event_timeout_minutes: description: - timeout time for termination notification event - in range between 5 and 15
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: overprovision: true 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: CoreOS publisher: CoreOS sku: Stable version: 899.17.0 osDisk: caching: ReadWrite createOption: fromImage managedDisk: storageAccountType: Standard_LRS sku: capacity: 2 name: Standard_DS1_v2 tier: Standard tags: null type: Microsoft.Compute/virtualMachineScaleSets type: dict