Skip to content

Commit

Permalink
ensure we don't get a None in the host list
Browse files Browse the repository at this point in the history
This can happen is a host is found but doesnt match any of the `hostnames` rules.
  • Loading branch information
goneri committed Sep 27, 2022
1 parent 1ec2a18 commit 510d80f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/inventory/aws_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,10 @@ def _add_hosts(self, hosts, group, hostnames, allow_duplicated_hosts=False):
for host in hosts:
if allow_duplicated_hosts:
hostname_list = self.get_all_hostnames(host, hostnames)
elif preferred_hostname := self._get_preferred_hostname(host, hostnames):
hostname_list = [preferred_hostname]
else:
hostname_list = [self._get_preferred_hostname(host, hostnames)]
continue

host = camel_dict_to_snake_dict(host, ignore_list=['Tags'])
host['tags'] = boto3_tag_list_to_ansible_dict(host.get('tags', []))
Expand Down

0 comments on commit 510d80f

Please sign in to comment.