Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #1582/ee68be3d backport][stable-6] aws_ec2 inventory : Modify accepted type for hostnames argument in the module doc #1591

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/ec2-inventory-hostnames-doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trivial:
- "Module documetation fix for hostnames argument. It can be list of str and dict."
12 changes: 8 additions & 4 deletions plugins/inventory/aws_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@
hostnames:
description:
- A list in order of precedence for hostname variables.
- The elements of the list can be a dict with the keys mentioned below or a string.
- Can be one of the options specified in U(http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options).
- If value provided does not exist in the above options, it will be used as a literal string.
- 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
elements: dict
elements: raw
default: []
suboptions:
name:
description:
- Name of the host.
- Can be one of 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.
- If value provided does not exist in the above options, it will be used as a literal string.
type: str
required: True
prefix:
Expand Down Expand Up @@ -773,6 +774,9 @@ def parse(self, inventory, loader, path, cache=True):
use_contrib_script_compatible_ec2_tag_keys = self.get_option("use_contrib_script_compatible_ec2_tag_keys")
use_ssm_inventory = self.get_option("use_ssm_inventory")

if not all(isinstance(element, (dict, str)) for element in hostnames):
self.fail_aws("Hostnames should be a list of dict and str.")

if self.get_option("include_extra_api_calls"):
self.display.deprecate(
"The include_extra_api_calls option has been deprecated and will be removed in release 6.0.0.",
Expand Down