ansible / ansible.builtin / v2.9.7 / inventory / aws_ec2 EC2 inventory source Authors: Sloane Hertel (@s-hertel)ansible.builtin.aws_ec2 (v2.9.7) — inventory
pip
Install with pip install ansible==2.9.7
Get inventory hosts from Amazon Web Services EC2.
Uses a YAML configuration file that ends with C(aws_ec2.(yml|yaml)).
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 groups: default: {} description: Add hosts to group based on Jinja2 conditionals. type: dict plugin: choices: - aws_ec2 description: Token that ensures this is a source file for the plugin. required: true 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: default: {} description: - A dictionary of filter value pairs. - Available filters are listed here U(http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options). type: dict regions: default: [] description: - A list of regions in which to describe EC2 instances. - If empty (the default) default this will include all regions, except possibly restricted ones like us-gov-west-1 and cn-north-1. type: list hostnames: default: [] description: - A list in order of precedence for hostname variables. - You can use the options specified in U(http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options). - To use tags as hostnames use the syntax tag:Name=Value to use the hostname Name_Value, or tag:Name to use the value of the Name tag. type: list aws_profile: aliases: - boto_profile description: The AWS profile env: - name: AWS_DEFAULT_PROFILE - name: AWS_PROFILE type: str 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 iam_role_arn: description: The ARN of the IAM role to assume to perform the inventory lookup. You should still provide AWS credentials with enough privilege to perform the AssumeRole action. version_added: '2.9' version_added_collection: ansible.builtin 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 aws_access_key: aliases: - aws_access_key_id description: The AWS access key to use. env: - name: EC2_ACCESS_KEY - name: AWS_ACCESS_KEY - name: AWS_ACCESS_KEY_ID type: str aws_secret_key: aliases: - aws_secret_access_key description: The AWS secret key that corresponds to the access key. env: - name: EC2_SECRET_KEY - name: AWS_SECRET_KEY - name: AWS_SECRET_ACCESS_KEY type: str 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 aws_security_token: description: The AWS security token if using temporary access and secret keys. env: - name: EC2_SECURITY_TOKEN - name: AWS_SESSION_TOKEN - name: AWS_SECURITY_TOKEN type: str strict_permissions: default: true description: - By default if a 403 (Forbidden) error code is encountered this plugin will fail. - You can set this option to False in the inventory config file which will allow 403 errors to be gracefully skipped. type: bool include_extra_api_calls: default: false description: - Add two additional API calls for every instance to include 'persistent' and 'events' host variables. - Spot instances may be persistent and instances may have associated events. type: bool version_added: '2.8' 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 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