salt.cloud.clouds.azurearm

Azure ARM Cloud Module

New in version 2016.11.0.

Changed in version 2019.2.0.

The Azure ARM cloud module is used to control access to Microsoft Azure Resource Manager

depends
configuration

Required provider parameters:

if using username and password:
  • subscription_id

  • username

  • password

if using a service principal:
  • subscription_id

  • tenant

  • client_id

  • secret

if using Managed Service Identity authentication:
  • subscription_id

Optional provider parameters:

cloud_environment: Used to point the cloud driver to different API endpoints, such as Azure GovCloud. Possible values:
  • AZURE_PUBLIC_CLOUD (default)

  • AZURE_CHINA_CLOUD

  • AZURE_US_GOV_CLOUD

  • AZURE_GERMAN_CLOUD

  • HTTP base URL for a custom endpoint, such as Azure Stack. The /metadata/endpoints path will be added to the URL.

userdata and userdata_file:

Azure Resource Manager uses a separate VirtualMachineExtension object to pass userdata scripts to the virtual machine. Arbitrary shell commands can be passed via the userdata parameter, or via a file local to the Salt Cloud system using the userdata_file parameter. Note that the local file is not treated as a script by the extension, so "one-liners" probably work best. If greater functionality is desired, a web-hosted script file can be specified via userdata_file: https://raw.githubusercontent.com/account/repo/master/azure-script.py, which will be executed on the system after VM creation. For Windows systems, script files ending in .ps1 will be executed with powershell.exe. The userdata parameter takes precedence over the userdata_file parameter when creating the custom script extension.

win_installer:

This parameter, which holds the local path to the Salt Minion installer package, is used to determine if the virtual machine type will be "Windows". Only set this parameter on profiles which install Windows operating systems.

Example /etc/salt/cloud.providers or /etc/salt/cloud.providers.d/azure.conf configuration:

my-azure-config with username and password:
  driver: azurearm
  subscription_id: 3287abc8-f98a-c678-3bde-326766fd3617
  username: larry
  password: 123pass

Or my-azure-config with service principal:
  driver: azurearm
  subscription_id: 3287abc8-f98a-c678-3bde-326766fd3617
  tenant: ABCDEFAB-1234-ABCD-1234-ABCDEFABCDEF
  client_id: ABCDEFAB-1234-ABCD-1234-ABCDEFABCDEF
  secret: XXXXXXXXXXXXXXXXXXXXXXXX
  cloud_environment: AZURE_US_GOV_CLOUD

  The Service Principal can be created with the new Azure CLI (https://github.com/Azure/azure-cli) with:
  az ad sp create-for-rbac -n "http://<yourappname>" --role <role> --scopes <scope>
  For example, this creates a service principal with 'owner' role for the whole subscription:
  az ad sp create-for-rbac -n "http://mysaltapp" --role owner --scopes /subscriptions/3287abc8-f98a-c678-3bde-326766fd3617

  *Note: review the details of Service Principals. Owner role is more than you normally need, and you can restrict
  scope to a resource group or individual resources.
salt.cloud.clouds.azurearm.avail_images(call=None)

Return a dict of all available images on the provider

salt.cloud.clouds.azurearm.avail_locations(call=None)

Return a dict of all available regions.

salt.cloud.clouds.azurearm.avail_sizes(call=None)

Return a list of sizes available from the provider

salt.cloud.clouds.azurearm.create(vm_)

Create a single VM from a data dict.

salt.cloud.clouds.azurearm.create_network_interface(call=None, kwargs=None)

Create a network interface.

salt.cloud.clouds.azurearm.create_or_update_vmextension(call=None, kwargs=None)

New in version 2019.2.0.

Create or update a VM extension object "inside" of a VM object.

required kwargs:
extension_name: myvmextension
virtual_machine_name: myvm
settings: {"commandToExecute": "hostname"}
optional kwargs:
resource_group: < inferred from cloud configs >
location: < inferred from cloud configs >
publisher: < default: Microsoft.Azure.Extensions >
virtual_machine_extension_type: < default: CustomScript >
type_handler_version: < default: 2.0 >
auto_upgrade_minor_version: < default: True >
protected_settings: < default: None >
salt.cloud.clouds.azurearm.delete_blob(call=None, kwargs=None)

Delete a blob from a container.

salt.cloud.clouds.azurearm.delete_interface(call=None, kwargs=None)

Delete a network interface.

salt.cloud.clouds.azurearm.delete_managed_disk(call=None, kwargs=None)

Delete a managed disk from a resource group.

salt.cloud.clouds.azurearm.destroy(name, call=None, kwargs=None)

Destroy a VM.

CLI Examples:

salt-cloud -d myminion
salt-cloud -a destroy myminion service_name=myservice
salt.cloud.clouds.azurearm.get_api_versions(call=None, kwargs=None)

Get a resource type api versions

salt.cloud.clouds.azurearm.get_configured_provider()

Return the first configured provider instance.

salt.cloud.clouds.azurearm.get_conn(client_type)

Return a connection object for a client type.

salt.cloud.clouds.azurearm.get_dependencies()

Warn if dependencies aren't met.

salt.cloud.clouds.azurearm.get_location(call=None, kwargs=None)

Return the location that is configured for this provider

salt.cloud.clouds.azurearm.get_resource_by_id(resource_id, api_version, extract_value=None)

Get an AzureARM resource by id

salt.cloud.clouds.azurearm.list_blobs(call=None, kwargs=None)

List blobs.

salt.cloud.clouds.azurearm.list_nodes(call=None)

List VMs on this Azure account

salt.cloud.clouds.azurearm.list_nodes_full(call=None)

List all VMs on the subscription with full information

salt.cloud.clouds.azurearm.list_resource_groups(call=None)

List resource groups associated with the subscription

salt.cloud.clouds.azurearm.list_storage_accounts(call=None)

List storage accounts within the subscription.

salt.cloud.clouds.azurearm.list_subnets(call=None, kwargs=None)

List subnets in a virtual network.

salt.cloud.clouds.azurearm.list_virtual_networks(call=None, kwargs=None)

List virtual networks.

salt.cloud.clouds.azurearm.request_instance(vm_)

Request a VM from Azure.

salt.cloud.clouds.azurearm.show_instance(name, call=None)

Show the details from AzureARM concerning an instance

salt.cloud.clouds.azurearm.start(name, call=None)

New in version 2019.2.0.

Start a VM

CLI Examples:

salt-cloud -a start myminion
salt.cloud.clouds.azurearm.stop(name, call=None)

New in version 2019.2.0.

Stop (deallocate) a VM

CLI Examples:

salt-cloud -a stop myminion