Skip to content

Commit

Permalink
aws_ec2 inventory : Modify accepted type for hostnames argument in th…
Browse files Browse the repository at this point in the history
…e module doc (#1582)

aws_ec2 inventory : Modify accepted type for hostnames argument in the module doc

SUMMARY


Fixes #1460
The argument hostnames is of type list, whose elements can be string and dict.
ISSUE TYPE


Docs Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell
Reviewed-by: Alina Buzachis
  • Loading branch information
GomathiselviS authored Jun 2, 2023
1 parent 463d588 commit ee68be3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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 @@ -776,6 +777,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

0 comments on commit ee68be3

Please sign in to comment.