Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/79459-fix-meta-task-check.yml
@@ -0,0 +1,2 @@
bugfixes:
- "Fix a traceback occuring when a task is named ``meta`` (https://github.com/ansible/ansible/issues/79459)"
2 changes: 1 addition & 1 deletion lib/ansible/playbook/task.py
Expand Up @@ -138,7 +138,7 @@ def load(data, block=None, role=None, task_include=None, variable_manager=None,

def __repr__(self):
''' 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']
else:
return "TASK: %s" % self.get_name()
Expand Down
12 changes: 12 additions & 0 deletions test/integration/targets/tasks/playbook.yml
@@ -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
3 changes: 3 additions & 0 deletions test/integration/targets/tasks/runme.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ansible-playbook playbook.yml
4 changes: 0 additions & 4 deletions test/integration/targets/tasks/tasks/main.yml

This file was deleted.