diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2023-03-31 11:37:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-31 11:37:17 -0400 |
commit | 4b20191c52721930965ad96e9acca02f0227bc96 (patch) | |
tree | 6a45c9f0672950bcd8306cf7c9963edf6cfee0b0 | |
parent | 043a0f3ee81c6a56b025f4c2f3e939c5d621fba8 (diff) | |
download | ansible-4b20191c52721930965ad96e9acca02f0227bc96.tar.gz |
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'.
-rw-r--r-- | changelogs/fragments/listalltags.yml | 2 | ||||
-rwxr-xr-x | lib/ansible/cli/playbook.py | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/changelogs/fragments/listalltags.yml b/changelogs/fragments/listalltags.yml new file mode 100644 index 0000000000..c1c5feae95 --- /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 c94cf0ff77..7d2dbc02f0 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) |