ansible.builtin.gcp_compute (v2.9.27) — inventory

Google Cloud Compute Engine inventory source

Authors: unknown

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Get inventory hosts from Google Cloud Platform GCE.

Uses a YAML configuration file that ends with gcp_compute.(yml|yaml) or gcp.(yml|yaml).


Requirements

Inputs

    
cache:
    default: false
    description:
    - Toggle to enable/disable the caching of the inventory's source data, requires a
      cache plugin setup to work.
    env:
    - name: ANSIBLE_INVENTORY_CACHE
    ini:
    - key: cache
      section: inventory
    type: bool

zones:
    description: A list of regions in which to describe GCE instances. If none provided,
      it defaults to all zones available to a given project.
    type: list

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

plugin:
    choices:
    - gcp_compute
    description: token that ensures this is a source file for the 'gcp_compute' plugin.
    required: true

scopes:
    default:
    - https://www.googleapis.com/auth/compute
    description: list of authentication scopes
    env:
    - name: GCP_SCOPES
      version_added: 2.8.2
      version_added_collection: ansible.builtin
    type: list

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

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

filters:
    description: 'A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/compute/docs/reference/rest/v1/instances/aggregatedList).
      Each additional filter in the list will act be added as an AND condition (filter1
      and filter2)

      '
    type: list

projects:
    description: A list of projects in which to describe GCE instances.
    required: true
    type: list

auth_kind:
    choices:
    - application
    - serviceaccount
    - machineaccount
    description:
    - The type of credential used.
    env:
    - name: GCP_AUTH_KIND
      version_added: 2.8.2
      version_added_collection: ansible.builtin
    required: true

hostnames:
    default:
    - public_ip
    - private_ip
    - name
    description: A list of options that describe the ordering for which hostnames should
      be assigned. Currently supported hostnames are 'public_ip', 'private_ip', or 'name'.
    type: list

vars_prefix:
    default: ''
    description: prefix to apply to host variables, does not include facts nor params

cache_plugin:
    default: memory
    description:
    - Cache plugin to use for the inventory's source data.
    env:
    - name: ANSIBLE_CACHE_PLUGIN
    - name: ANSIBLE_INVENTORY_CACHE_PLUGIN
    ini:
    - key: fact_caching
      section: defaults
    - key: cache_plugin
      section: inventory
    type: str

cache_prefix:
    default: ansible_inventory_
    description:
    - Prefix to use for cache plugin files/tables
    env:
    - name: ANSIBLE_CACHE_PLUGIN_PREFIX
    - name: ANSIBLE_INVENTORY_CACHE_PLUGIN_PREFIX
    ini:
    - key: fact_caching_prefix
      section: defaults
    - key: cache_prefix
      section: inventory

keyed_groups:
    default: []
    description: Add hosts to group based on the values of a variable.
    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

cache_timeout:
    default: 3600
    description:
    - Cache duration in seconds
    env:
    - name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
    - name: ANSIBLE_INVENTORY_CACHE_TIMEOUT
    ini:
    - key: fact_caching_timeout
      section: defaults
    - key: cache_timeout
      section: inventory
    type: int

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

cache_connection:
    description:
    - Cache connection data or path, read cache plugin documentation for specifics.
    env:
    - name: ANSIBLE_CACHE_PLUGIN_CONNECTION
    - name: ANSIBLE_INVENTORY_CACHE_CONNECTION
    ini:
    - key: fact_caching_connection
      section: defaults
    - key: cache_connection
      section: inventory
    type: str

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

retrieve_image_info:
    default: false
    description:
    - Populate the C(image) host fact for the instances returned with the GCP image name
    - By default this plugin does not attempt to resolve the boot image of an instance
      to the image name cataloged in GCP because of the performance overhead of the task.
    - Unless this option is enabled, the C(image) host variable will be C(null)
    type: bool
    version_added: '2.8'
    version_added_collection: ansible.builtin

service_account_file:
    description:
    - The path of a Service Account JSON file if serviceaccount is selected as type.
    env:
    - name: GCP_SERVICE_ACCOUNT_FILE
      version_added: 2.8.2
      version_added_collection: ansible.builtin
    - name: GCE_CREDENTIALS_FILE_PATH
      version_added: '2.8'
      version_added_collection: ansible.builtin
    type: path

service_account_email:
    description:
    - An optional service account email address if machineaccount is selected and the
      user does not wish to use the default email.
    env:
    - name: GCP_SERVICE_ACCOUNT_EMAIL
      version_added: 2.8.2
      version_added_collection: ansible.builtin

service_account_contents:
    description:
    - A string representing the contents of a Service Account JSON file. This should not
      be passed in as a dictionary, but a string that has the exact contents of a service
      account json file (valid JSON).
    env:
    - name: GCP_SERVICE_ACCOUNT_CONTENTS
    type: string
    version_added: 2.8.2
    version_added_collection: ansible.builtin

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