Fix repr(Task) to check action when testing for a meta task (#79464)

Fixes #79459
pull/56508/merge
Martin Krizek 2 years ago committed by GitHub
parent 01ff57bdff
commit 3bda4eae6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- "Fix a traceback occuring when a task is named ``meta`` (https://github.com/ansible/ansible/issues/79459)"

@ -138,7 +138,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch):
def __repr__(self): def __repr__(self):
''' returns a human readable representation of the task ''' ''' returns a human readable representation of the task '''
if self.get_name() in C._ACTION_META: if self.action in C._ACTION_META:
return "TASK: meta (%s)" % self.args['_raw_params'] return "TASK: meta (%s)" % self.args['_raw_params']
else: else:
return "TASK: %s" % self.get_name() return "TASK: %s" % self.get_name()

@ -0,0 +1,12 @@
- hosts: localhost
gather_facts: false
tasks:
# make sure tasks with an undefined variable in the name are gracefully handled
- name: "Task name with undefined variable: {{ not_defined }}"
debug:
msg: Hello
# ensure we properly test for an action name, not a task name when cheking for a meta task
- name: "meta"
debug:
msg: Hello

@ -0,0 +1,3 @@
#!/usr/bin/env bash
ansible-playbook playbook.yml

@ -1,4 +0,0 @@
# make sure tasks with an undefined variable in the name are gracefully handled
- name: "Task name with undefined variable: {{ not_defined }}"
debug:
msg: Hello
Loading…
Cancel
Save