azure.azcollection.azure_rm (2.3.0) — inventory

Azure Resource Manager inventory plugin

Authors: unknown

Install collection

Install with ansible-galaxy collection install azure.azcollection:==2.3.0


Add to requirements.yml

  collections:
    - name: azure.azcollection
      version: 2.3.0

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

    
groups:
    default: {}
    description: Add hosts to group based on Jinja2 conditionals.
    type: dict

plugin:
    choices:
    - azure_rm
    - azure.azcollection.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

strict:
    default: false
    description:
    - If V(yes) make invalid entries a fatal error, otherwise skip and continue.
    - Since it is possible to use facts in the expressions they might not always be available
      and we ignore those errors by default.
    type: bool

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

compose:
    default: {}
    description: Create vars from jinja2 expressions.
    type: dict

profile:
    description:
    - Security profile found in ~/.azure/credentials file.
    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

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

hostnames:
    default:
    - default
    description:
    - A list of Jinja2 expressions in order of precedence to compose inventory_hostname.
    - Ignores expression if result is an empty string or None value.
    - By default, inventory_hostname is generated to be globally unique based on the VM
      host name. See C(plain_host_names) for more details on the default.
    - An expression of C(default) will force using the default hostname generator if no
      previous hostname expression resulted in a valid hostname.
    - Use C(default_inventory_hostname) to access the default hostname generator's value
      in any of the Jinja2 expressions.
    elements: 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

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:
    default: []
    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(_))
    elements: dict
    suboptions:
      default_value:
        description:
        - The default value when the host variable's value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].trailing_separator).
        type: str
        version_added: '2.12'
        version_added_collection: ansible.builtin
      key:
        description:
        - The key from input dictionary used to generate groups
        type: str
      parent_group:
        description: parent group for keyed group
        type: str
      prefix:
        default: ''
        description: A keyed group name will start with this prefix
        type: str
      separator:
        default: _
        description: separator used to build the keyed group name
        type: str
      trailing_separator:
        default: true
        description:
        - Set this option to V(False) to omit the O(keyed_groups[].separator) after the
          host variable when the value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].default_value).
        type: bool
        version_added: '2.12'
        version_added_collection: ansible.builtin
    type: list

use_extra_vars:
    default: false
    description: Merge extra vars into the available variables for composition (highest
      precedence).
    env:
    - name: ANSIBLE_INVENTORY_USE_EXTRA_VARS
    ini:
    - key: use_extra_vars
      section: inventory_plugins
    type: bool
    version_added: '2.11'
    version_added_collection: ansible.builtin

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: 0.0.1
    version_added_collection: azure.azcollection

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

leading_separator:
    default: true
    description:
    - Use in conjunction with keyed_groups.
    - By default, a keyed group that does not have a prefix or a separator provided will
      have a name that starts with an underscore.
    - This is because the default prefix is "" and the default separator is "_".
    - Set this option to False to omit the leading underscore (or other separator) if
      no prefix is given.
    - If the group name is derived from a mapping the separator is still used to concatenate
      the items.
    - To not use a separator in the group name at all, set the separator for the keyed
      group to an empty string instead.
    type: boolean
    version_added: '2.11'
    version_added_collection: ansible.builtin

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.

include_host_filters:
    default:
    - true
    description: Include 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 included in the inventory, all hosts are includes in the inventory by
      default.

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

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)

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

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. Can also be set comma separated
      resource group names via the C(ANSIBLE_AZURE_VM_RESOURCE_GROUPS) environment variable.

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 C(replace_dash_in_groups) option is set to C(false).
      To replicate behavior of C(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: 0.0.1
    version_added_collection: azure.azcollection

See also