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

fixes #75354
pull/75559/head
Brian Coca 3 years ago committed by GitHub
parent a661e44f6e
commit ff72908b4d
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