Fix --list-hosts when undefined var is used (#75533) (#75551)

fixes #75354

(cherry picked from commit ff72908b4d)
pull/75623/head
Brian Coca 3 years ago committed by GitHub
parent d6da3b8c85
commit 8b34aab732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- ansible-playbook, more robust handling of --list-hosts and undefined vars in hosts keyword.

@ -147,7 +147,13 @@ class PlaybookCLI(CLI):
pb_dir = os.path.realpath(os.path.dirname(p['playbook']))
loader.set_basedir(pb_dir)
msg = "\n play #%d (%s): %s" % (idx + 1, ','.join(play.hosts), play.name)
# show host list if we were able to template into a list
try:
host_list = ','.join(play.hosts)
except TypeError:
host_list = ''
msg = "\n play #%d (%s): %s" % (idx + 1, host_list, play.name)
mytags = set(play.tags)
msg += '\tTAGS: [%s]' % (','.join(mytags))

Loading…
Cancel
Save