From 4b20191c52721930965ad96e9acca02f0227bc96 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 31 Mar 2023 11:37:17 -0400 Subject: [PATCH] list all tags (including never) when listing tags (#80309) * Ensure we default to show all tags when listing tags 'never' was being excluded by default,as it is not part of the 'run tags' runtime default ('all'). For listing we now add it to the default 'run tags'. --- changelogs/fragments/listalltags.yml | 2 ++ lib/ansible/cli/playbook.py | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 changelogs/fragments/listalltags.yml diff --git a/changelogs/fragments/listalltags.yml b/changelogs/fragments/listalltags.yml new file mode 100644 index 00000000000..c1c5feae959 --- /dev/null +++ b/changelogs/fragments/listalltags.yml @@ -0,0 +1,2 @@ +bugfixes: + - list-tags now shows the 'never' tag, which was being excluded by default. To list all tasks you still need to add `--list-tasks --tags never,all`. diff --git a/lib/ansible/cli/playbook.py b/lib/ansible/cli/playbook.py index c94cf0ff771..7d2dbc02f06 100755 --- a/lib/ansible/cli/playbook.py +++ b/lib/ansible/cli/playbook.py @@ -65,8 +65,19 @@ class PlaybookCLI(CLI): self.parser.add_argument('args', help='Playbook(s)', metavar='playbook', nargs='+') def post_process_args(self, options): + + # for listing, we need to know if user had tag input + # capture here as parent function sets defaults for tags + havetags = bool(options.tags or options.skip_tags) + options = super(PlaybookCLI, self).post_process_args(options) + if options.listtags: + # default to all tags (including never), when listing tags + # unless user specified tags + if not havetags: + options.tags = ['never', 'all'] + display.verbosity = options.verbosity self.validate_conflicts(options, runas_opts=True, fork_opts=True)