ansible.builtin.azure_rm (v2.9.17) — inventory

Azure Resource Manager inventory plugin

Authors: unknown

Install Ansible via pip

Install with pip install ansible==2.9.17

Description

Query VM details from Azure Resource Manager

Requires a YAML configuration file whose name ends with 'azure_rm.(yml|yaml)'

By default, sets C(ansible_host) to the first public IP address found (preferring the primary NIC). If no public IPs are found, the first private IP (also preferring the primary NIC). The default may be overridden via C(hostvar_expressions); see examples.


Requirements

Inputs

    
plugin:
    choices:
    - azure_rm
    description: marks this as an instance of the 'azure_rm' plugin
    required: true

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

profile:
    description:
    - Security profile found in ~/.azure/credentials file.
    type: str

password:
    description:
    - Active Directory user password. Use when authenticating with an Active Directory
      user rather than service principal.
    type: str

client_id:
    description:
    - Azure client ID. Use when authenticating with a Service Principal.
    type: str

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

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

batch_fetch:
    default: true
    description: To improve performance, results are fetched using an unsupported batch
      API. Disabling C(batch_fetch) uses a much slower serial fetch, resulting in many
      more round-trips. Generally only useful for troubleshooting.

keyed_groups:
    description: Creates groups based on the value of a host variable. Requires a list
      of dictionaries, defining C(key) (the source dictionary-typed variable), C(prefix)
      (the prefix to use for the new group name), and optionally C(separator) (which defaults
      to C(_))

subscription_id:
    description:
    - Your Azure subscription Id.
    type: str

plain_host_names:
    default: false
    description:
    - By default this plugin will use globally unique host names. This option allows you
      to override that, and use the name that matches the old inventory script naming.
    - This is not the default, as these names are not truly unique, and can conflict with
      other hosts. The default behavior will add extra hashing to the end of the hostname
      to prevent such conflicts.
    type: bool
    version_added: '2.8'
    version_added_collection: ansible.builtin

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

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

conditional_groups:
    description: A mapping of group names to Jinja2 expressions. When the mapped expression
      is true, the host is added to the named group.

hostvar_expressions:
    description: A mapping of hostvar names to Jinja2 expressions. The value for each
      host is the result of the Jinja2 expression (which may refer to any of the host's
      existing variables at the time this inventory plugin runs).

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

default_host_filters:
    default:
    - powerstate != "running"
    - provisioning_state != "succeeded"
    description: A default set of filters that is applied in addition to the conditions
      in C(exclude_host_filters) to exclude powered-off and not-fully-provisioned hosts.
      Set this to a different value or empty list if you need to include hosts in these
      states.

exclude_host_filters:
    default: []
    description: Excludes hosts from the inventory with a list of Jinja2 conditional expressions.
      Each expression in the list is evaluated for each host; when the expression is true,
      the host is excluded from the inventory.

fail_on_template_errors:
    choices:
    - true
    - false
    default: true
    description: When false, template failures during group and filter processing are
      silently ignored (eg, if a filter or group expression refers to an undefined host
      variable)

include_vm_resource_groups:
    default:
    - '*'
    description: A list of resource group names to search for virtual machines. '\*' will
      include all resource groups in the subscription.

include_vmss_resource_groups:
    default: []
    description: A list of resource group names to search for virtual machine scale sets
      (VMSSs). '\*' will include all resource groups in the subscription.

use_contrib_script_compatible_sanitization:
    default: false
    description:
    - By default this plugin is using a general group name sanitization to create safe
      and usable group names for use in Ansible. This option allows you to override that,
      in efforts to allow migration from the old inventory script and matches the sanitization
      of groups when the script's ``replace_dash_in_groups`` option is set to ``False``.
      To replicate behavior of ``replace_dash_in_groups = True`` with constructed groups,
      you will need to replace hyphens with underscores via the regex_replace filter for
      those entries.
    - For this to work you should also turn off the TRANSFORM_INVALID_GROUP_CHARS setting,
      otherwise the core engine will just use the standard sanitization on top.
    - This is not the default as such names break certain functionality as not all characters
      are valid Python identifiers which group names end up being used as.
    type: bool
    version_added: '2.8'
    version_added_collection: ansible.builtin

See also