Skip to content

melmorabity/ansible-azure-rm-resource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

azure_rm_resource

Manage Azure resources.

Synopsis

Create, update or delete an Azure resource.

Requirements

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

  • azure >= 2.0.0

Options

parameter required default choices comments
resource_group yes Name of resource group.
ad_user no Active Directory username. Use when authenticating with an Active Directory user rather than service principal.
managed_by no ID of the resource that manages this resource.
sku no Sku of the resource.
provider_namespace yes Resource provider namespace.
append_tags no True 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.
cloud_environment 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.
state no present
  • present
  • absent
Assert the state of the resource.
secret no Azure client secret. Use when authenticating with a Service Principal.
location no resource_group location Valid Azure location. Defaults to location of the resource group.
subscription_id no Your Azure subscription Id.
parent_resource_path no Parent resource path.
profile no Security profile found in ~/.azure/credentials file.
tags no Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object will be updated with any provided values.
update no True Use to control if resource parameters must be updated if the resource exists. If enabled, the resource will be updated with specified parameters.
plan no Plan of the resource.
client_id no Azure client ID. Use when authenticating with a Service Principal.
password no Active Directory user password. Use when authenticating with an Active Directory user rather than service principal.
properties no Resource properties.
tenant no Azure tenant ID. Use when authenticating with a Service Principal.
kind no Kind of the resource.
name yes Name of the resource.
identity no Identity of the resource.
resource_type yes Resource type.

Examples

# Note: None of these examples set subscription_id, client_id, client_secret and
# tenant_id. It is assumed that their matching environment variables are set.

# Add tags to an existing virtual machine and change its size
- local_action:
    module: azure_rm_resource
    resource_group: my_resoure_group
    provider_namespace: Microsoft.Compute
    type: virtualMachines
    name: my_virtual_machine
    tags:
      key: value
    properties:
      hardwareProfile:
        vmSize: Standard_D2_v2

# Delete a virtual machine
- local_action:
    module: azure_rm_resource
    resource_group: my_resoure_group
    provider_namespace: Microsoft.Compute
    type: virtualMachines
    name: my_virtual_machine
    state: absent

Notes

  • 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.

Releases

No releases published

Packages

No packages published

Languages