# How to avoid repetitive entries?

**URL:** <https://forum.ansible.com/t/how-to-avoid-repetitive-entries/16248>\
**Category:** Ansible Project\
**Created:** [September 16, 2014, 5:30pm UTC](https://forum.ansible.com/t/how-to-avoid-repetitive-entries/16248 "2014-09-16T17:30:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hilco\_Wijbenga](https://avatars.discourse-cdn.com/v4/letter/h/d2c977/32.png) [@Hilco\_Wijbenga](https://forum.ansible.com/u/Hilco_Wijbenga)\
**Post date:** [September 16, 2014, 5:30pm UTC](https://forum.ansible.com/t/how-to-avoid-repetitive-entries/16248/1 "2014-09-16T17:30:47Z")

</div>

Hi all,

I have a "user-vars.yml" file that contains a user and password. I  
also want to set "sudo: True" and "remote\_user: root". Right now I  
repeat all that per hosts entry:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 16, 2014, 5:45pm UTC](https://forum.ansible.com/t/how-to-avoid-repetitive-entries/16248/2 "2014-09-16T17:45:21Z")

</div>

Generally I consider it an important part of play documentation though some of these defaults can be set in ansible.cfg.

You can also set variables like “ansible\_ssh\_user” and “ansible\_sudo” (boolean) in variables.

---

<div class="post-metadata">

**Author:** ![Hilco\_Wijbenga](https://avatars.discourse-cdn.com/v4/letter/h/d2c977/32.png) [@Hilco\_Wijbenga](https://forum.ansible.com/u/Hilco_Wijbenga)\
**Post date:** [September 16, 2014, 5:52pm UTC](https://forum.ansible.com/t/how-to-avoid-repetitive-entries/16248/3 "2014-09-16T17:52:46Z")

</div>

> Generally I consider it an important part of play documentation though some  
> of these defaults can be set in ansible.cfg.

Actually, I noticed that even these repeated settings do not work. It  
seems this actually needs to be done at the role level?

> You can also set variables like "ansible\_ssh\_user" and "ansible\_sudo"  
> (boolean) in variables.

Ah, yes, I had actually noticed "remote\_user" but "ansible\_sudo" seems  
undocumented? At least Google didn't know about it.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 16, 2014, 5:58pm UTC](https://forum.ansible.com/t/how-to-avoid-repetitive-entries/16248/4 "2014-09-16T17:58:55Z")

</div>

“Actually, I noticed that even these repeated settings do not work. It  
seems this actually needs to be done at the role level?”

Those settings where you have them are correct.

I’m not sure what “doesn’t work” means in your case, you’ll have to provide a bit more info/output there.

Yes, ansible\_sudo does appear undocumented, as does the ansible\_su boolean which does the same thing.

Normally something we’d refer to in the “Magic Variables” section at least.

Do you mind filing a ticket about that one? We can add those in.

---

<div class="post-metadata">

**Author:** ![Hilco\_Wijbenga](https://avatars.discourse-cdn.com/v4/letter/h/d2c977/32.png) [@Hilco\_Wijbenga](https://forum.ansible.com/u/Hilco_Wijbenga)\
**Post date:** [September 16, 2014, 6:49pm UTC](https://forum.ansible.com/t/how-to-avoid-repetitive-entries/16248/5 "2014-09-16T18:49:00Z")

</div>

> "Actually, I noticed that even these repeated settings do not work. It  
> seems this actually needs to be done at the role level?"
> 
> Those settings where you have them are correct.
> 
> I'm not sure what "doesn't work" means in your case, you'll have to provide  
> a bit more info/output there.

I use the variables in a template in a task:  
roles/role-1/tasks/task-1. If I do not include the user-vars.yml file  
again at the role level (mmm, or rather the task level, I guess)  
Ansible complains that it does not know about those variables. Hence  
my comment.

roles/role-1/tasks/task-1.yml:  
- name: ...

- include\_vars: user-vars.yml

- name: "task-name"  
&nbsp;&nbsp;template:  
&nbsp;&nbsp;&nbsp;&nbsp;src=template.j2  
&nbsp;&nbsp;&nbsp;&nbsp;dest=/etc/some-file

This fails without the "include\_vars" bit despite the inclusion higher up.

> Yes, ansible\_sudo does appear undocumented, as does the ansible\_su boolean  
> which does the same thing.
> 
> Normally something we'd refer to in the "Magic Variables" section at least.
> 
> Do you mind filing a ticket about that one? We can add those in.

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