# role|name of task bug with includes

**URL:** <https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518>\
**Category:** Ansible Developer\
**Created:** [September 20, 2013, 5:45pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518 "2013-09-20T17:45:59Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerome\_Wagner](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jerome\_Wagner](https://forum.ansible.com/u/Jerome_Wagner)\
**Post date:** [September 20, 2013, 5:45pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/1 "2013-09-20T17:45:59Z")

</div>

I re-post beneath the exchange with James Cammarata on ansible-project.

James, your patch

if os.path.isfile(handler):

- nt = dict(include=pipes.quote(handler), vars=role\_vars, role\_name=role[‘role’])

- nt = dict(include=pipes.quote(handler), vars=role\_vars)

is about the “notify: role|name of task” bug issue, you removed the prepending of role| in front of the handlers.

I thought it was on purpose that role| was added in front of handlers. Namespacing the handlers by role makes a lot of sense to me.

don’t you think it was acceptable as it was ? not a bug but a feature ?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 20, 2013, 5:51pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/2 "2013-09-20T17:51:11Z")

</div>

Task names should NOT be prepended either, just the output in the callbacks.

– Michael

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 20, 2013, 5:52pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/3 "2013-09-20T17:52:17Z")

</div>

That is a short-term fix so that people running from devel would not have their playbooks broken. I will get this fixed for handlers as well, however it will involve adding an additional field to the task structure to save the role name separately from the task name, and then having the output functions use that new field as well. That will take a bit more testing, so I wanted to get people back up and running that might be having issues with notifications. I definitely want the handlers to show the role namespace as well.

The above will also address what Michael was talking about.

Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 20, 2013, 5:52pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/4 "2013-09-20T17:52:29Z")

</div>

We do not want any backwards incompatible playbook changes where someone can’t notify a handler defined in another role.

– Michael

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 20, 2013, 5:53pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/5 "2013-09-20T17:53:31Z")

</div>

w00t

– Michael

---

<div class="post-metadata">

**Author:** ![Jerome\_Wagner](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jerome\_Wagner](https://forum.ansible.com/u/Jerome_Wagner)\
**Post date:** [September 20, 2013, 6:03pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/6 "2013-09-20T18:03:33Z")

</div>

Yes that’s a mighty goal. I understand this is important for the project.

I just thought that adding a level of role namespacing in the name of tasks was a super feature because I already sometimes have conflicting names like ‘restart service’. If a way can be found using the presence of ‘|’ to make this backwards compatible that’s great !

James thank you for commiting temp-fixes on devel I like being on the edge but playbooks that break are disappointing, even on devel 😉

regarding the role prefixing, I imagined the

role\>name of task becoming

my\_role\_dir/role|name of task  
or  
[http://ansible.mydomain.com/roles/nginx](http://ansible.mydomain.com/roles/nginx) | name of task

for such extensions & shareability of roles, the namespacing would be necessary to avoid naming conflicts I suppose.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 20, 2013, 6:05pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/7 "2013-09-20T18:05:49Z")

</div>

No to prefixing, need to assign service specific names

– Michael

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 20, 2013, 6:08pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/8 "2013-09-20T18:08:30Z")

</div>

Yeah that’s a lot of text on the line potentially, so best to keep your roles prefixed yourself to a degree. For instance, if you’re using a role from user foo you got from github, you could easily just name the role directory github.foo.rolename to namespace it yourself.

---

<div class="post-metadata">

**Author:** ![Jerome\_Wagner](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jerome\_Wagner](https://forum.ansible.com/u/Jerome_Wagner)\
**Post date:** [September 20, 2013, 6:14pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/9 "2013-09-20T18:14:19Z")

</div>

but from what I understand handler’s names are “global”

so you mean that people have to give a unique name to all their handlers across all their roles and all the roles of other people they will share roles with ?

I am not sure what happens a playbook discovers a handler with a name that a previous handler uses. Does it fail saying : you should rename your handler, this name is already taken ?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 20, 2013, 6:19pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/10 "2013-09-20T18:19:12Z")

</div>

It is currently hash merge related so it is NOT a problem if two roles define restart nginx

I consider this desirable and actually making sharing easier as they are likely to have the same definition anyway.

– Michael

---

<div class="post-metadata">

**Author:** ![Jerome\_Wagner](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jerome\_Wagner](https://forum.ansible.com/u/Jerome_Wagner)\
**Post date:** [September 20, 2013, 6:35pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/11 "2013-09-20T18:35:50Z")

</div>

I had a bug today :

a notify: restart nginx was apparently “restarting” nginx.  
the ansible output was “changed” and not “failed”  
but the server was not restarted.

after closer inquiry (and don’t ask why 😉 I had 2 handlers

- name: restart nginx  
service: name=nginx state=restarted

and

- name: restart nginx  
sudo\_user: root  
service: name=nginx state=restarted

the 2 were doing a “changed” but only the one with sudo\_user:root worked !

I have no explanation as to why it was/was not working but I was puzzled for some time.

If this kind of collision exists via shared roles it can become a nightmare I think.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 20, 2013, 10:14pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/12 "2013-09-20T22:14:54Z")

</div>

Most people set sudo on the play. Not too worried.

– Michael

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 20, 2013, 10:25pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/13 "2013-09-20T22:25:00Z")

</div>

The above callback method has been merged in, if you’d like to test it.

---

<div class="post-metadata">

**Author:** ![Jerome\_Wagner](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jerome\_Wagner](https://forum.ansible.com/u/Jerome_Wagner)\
**Post date:** [September 24, 2013, 12:27pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/14 "2013-09-24T12:27:10Z")

</div>

Hello,  
I just tested.

- (1) the notification is working ok, notified task has the r|
- (2) there is still a bug regarding the name of included tasks

in the (2) I a in the case where a role/r/tasks/main.yml has an include: install.yml directive

all the tasks in the install.yml file do not have the r| prepended in their name in the output.

do you confirm this is a bug ?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 24, 2013, 1:05pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/15 "2013-09-24T13:05:25Z")

</div>

Hi Jerome,

Thanks for the heads up, I would agree that includes should also prefix the name of the role.

Please make sure there is bug in github so we have a record of this.

---

<div class="post-metadata">

**Author:** ![Jerome\_Wagner](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jerome\_Wagner](https://forum.ansible.com/u/Jerome_Wagner)\
**Post date:** [September 24, 2013, 1:36pm UTC](https://forum.ansible.com/t/role-name-of-task-bug-with-includes/13518/16 "2013-09-24T13:36:37Z")

</div>

done  
[https://github.com/ansible/ansible/issues/4223](https://github.com/ansible/ansible/issues/4223)
