diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index 6700e4c3c97..216ddc61466 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -347,7 +347,12 @@ class PlayBook(object): ansible.callbacks.set_task(self.callbacks, task) ansible.callbacks.set_task(self.runner_callbacks, task) - self.callbacks.on_task_start(template(play.basedir, task.name, task.module_vars, lookup_fatal=False, filter_fatal=False), is_handler) + if task.role_name: + name = '%s|%s' % (task.role_name, task.name) + else: + name = task.name + + self.callbacks.on_task_start(template(play.basedir, name, task.module_vars, lookup_fatal=False, filter_fatal=False), is_handler) if hasattr(self.callbacks, 'skip_task') and self.callbacks.skip_task: ansible.callbacks.set_task(self.callbacks, None) ansible.callbacks.set_task(self.runner_callbacks, None) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 16eafc93da3..4781eb8d006 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -285,18 +285,20 @@ class Play(object): if not os.path.isfile(task) and not os.path.isfile(handler) and not os.path.isfile(vars_file) and not os.path.isdir(library): raise errors.AnsibleError("found role at %s, but cannot find %s or %s or %s or %s" % (role_path, task, handler, vars_file, library)) + + if isinstance(role, dict): + role_name = role['role'] + else: + role_name = role + if os.path.isfile(task): - if isinstance(role, dict): - role_name = role['role'] - else: - role_name = role nt = dict(include=pipes.quote(task), vars=role_vars, default_vars=default_vars, role_name=role_name) for k in special_keys: if k in special_vars: nt[k] = special_vars[k] new_tasks.append(nt) if os.path.isfile(handler): - nt = dict(include=pipes.quote(handler), vars=role_vars) + nt = dict(include=pipes.quote(handler), vars=role_vars, role_name=role_name) for k in special_keys: if k in special_vars: nt[k] = special_vars[k] diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index de6fba0c5d0..9c29593f6f1 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -25,7 +25,7 @@ class Task(object): __slots__ = [ 'name', 'meta', 'action', 'only_if', 'when', 'async_seconds', 'async_poll_interval', 'notify', 'module_name', 'module_args', 'module_vars', 'default_vars', - 'play', 'notified_by', 'tags', 'register', + 'play', 'notified_by', 'tags', 'register', 'role_name', 'delegate_to', 'first_available_file', 'ignore_errors', 'local_action', 'transport', 'sudo', 'sudo_user', 'sudo_pass', 'items_lookup_plugin', 'items_lookup_terms', 'environment', 'args', @@ -110,6 +110,7 @@ class Task(object): self.register = ds.get('register', None) self.sudo = utils.boolean(ds.get('sudo', play.sudo)) self.environment = ds.get('environment', {}) + self.role_name = role_name # rather than simple key=value args on the options line, these represent structured data and the values # can be hashes and lists, not just scalars @@ -159,10 +160,6 @@ class Task(object): if self.name is None: self.name = self.action - # prepend the role name this task is from, if there was one - if role_name: - self.name = "%s|%s" % (role_name, self.name) - # load various attributes self.only_if = ds.get('only_if', 'True') self.when = ds.get('when', None)