diff options
author | James Tanner <tanner.jc@gmail.com> | 2014-03-27 11:47:49 -0400 |
---|---|---|
committer | James Tanner <tanner.jc@gmail.com> | 2014-03-27 11:47:49 -0400 |
commit | c1f4142a295effd3a822c738c140c4fb61382e81 (patch) | |
tree | 1cb5d7a7a2d936a05a77b80cbcd4dfe458b11762 /bin/ansible-playbook | |
parent | 1faa840b6776990e5072a7d088a2c11f848f9c87 (diff) | |
download | ansible-c1f4142a295effd3a822c738c140c4fb61382e81.tar.gz |
Fixes #4109 Filter plays by tags when using --list-hosts
Diffstat (limited to 'bin/ansible-playbook')
-rwxr-xr-x | bin/ansible-playbook | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/bin/ansible-playbook b/bin/ansible-playbook index f54c17d7aa..ecfaf20b92 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -207,11 +207,9 @@ def main(args): play = ansible.playbook.Play(pb, play_ds, play_basedir) label = play.name hosts = pb.inventory.list_hosts(play.hosts) - if options.listhosts: - print ' play #%d (%s): host count=%d' % (playnum, label, len(hosts)) - for host in hosts: - print ' %s' % host - if options.listtasks: + + # Filter all tasks by given tags + if pb.only_tags != 'all': if options.subset and not hosts: continue matched_tags, unmatched_tags = play.compare_tags(pb.only_tags) @@ -225,9 +223,17 @@ def main(args): if unknown_tags: continue + + if options.listhosts: + print ' play #%d (%s): host count=%d' % (playnum, label, len(hosts)) + for host in hosts: + print ' %s' % host + + if options.listtasks: print ' play #%d (%s):' % (playnum, label) for task in play.tasks(): + print "tags: %s" % task.tags if (set(task.tags).intersection(pb.only_tags) and not set(task.tags).intersection(pb.skip_tags)): if getattr(task, 'name', None) is not None: |