# Using become: True for a specific role

**URL:** <https://forum.ansible.com/t/using-become-true-for-a-specific-role/10391>\
**Category:** Get Help\
**Created:** [October 18, 2024, 6:47am UTC](https://forum.ansible.com/t/using-become-true-for-a-specific-role/10391 "2024-10-18T06:47:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hieronymus](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hieronymus/32/1624_2.png) [@hieronymus](https://forum.ansible.com/u/hieronymus)\
**Post date:** [October 18, 2024, 6:47am UTC](https://forum.ansible.com/t/using-become-true-for-a-specific-role/10391/1 "2024-10-18T06:47:29Z")

</div>

Hi,  
I need to run only one role with the become egal true and I’m trying to call it with this value but ansible doesn’t appreciate it 😉  
I made several tests, here is one of them:

```auto
[...]
tasks:
  - name: include role with become true
    include_role:
      name: role_testing_variables
      apply:
        become: True
[...]

```

I’m not sure yet if it possible to do that with ansible?  
Please let me known what’s wrong or do you have any idea to resolve it?  
Regards, H

---

<div class="post-metadata">

**Author:** ![hieronymus](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hieronymus/32/1624_2.png) [@hieronymus](https://forum.ansible.com/u/hieronymus)\
**Post date:** [October 18, 2024, 7:55am UTC](https://forum.ansible.com/t/using-become-true-for-a-specific-role/10391/2 "2024-10-18T07:55:19Z")

</div>

Apparently it was a bug in Ansible version 2.4 [issue 35065](https://github.com/ansible/ansible/issues/35065) but I’m using the version 2.27.4.

Has anyone more infos about that?

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [October 18, 2024, 8:29am UTC](https://forum.ansible.com/t/using-become-true-for-a-specific-role/10391/3 "2024-10-18T08:29:56Z")

</div>

> [@hieronymus](#):
>
> I’m using the version 2.27.4.

You probably mean version 2.17.4?

The code you have provided should work. What error message do you get?

---

<div class="post-metadata">

**Author:** ![jrglynn2](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@jrglynn2](https://forum.ansible.com/u/jrglynn2)\
**Post date:** [October 18, 2024, 2:06pm UTC](https://forum.ansible.com/t/using-become-true-for-a-specific-role/10391/4 "2024-10-18T14:06:19Z")

</div>

> [@hieronymus](#):
>
> ```auto
> - name: include role with become true
> include_role:
> 
> ```

instead of this, wouldn’t it be:

```auto
  - name: include role with become true
    become: true
    include_role:

```

and remove the `apply` section?

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [October 18, 2024, 2:33pm UTC](https://forum.ansible.com/t/using-become-true-for-a-specific-role/10391/5 "2024-10-18T14:33:55Z")

</div>

> [@jrglynn2](#):
>
> and remove the `apply` section?

Nope, not for `ansible.builint.ínclude_role`. Ansible will fail with the following message if you do that:  
`ERROR! 'become' is not a valid attribute for a IncludeRole`

However, for `ansible.builtin.import_role` that is the way to go.

---

<div class="post-metadata">

**Author:** ![jrglynn2](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@jrglynn2](https://forum.ansible.com/u/jrglynn2)\
**Post date:** [October 18, 2024, 5:25pm UTC](https://forum.ansible.com/t/using-become-true-for-a-specific-role/10391/6 "2024-10-18T17:25:25Z")

</div>

> [@jiholland](#):
>
> However, for `ansible.builtin.import_role` that is the way to go.

Ahh, that is the distinction. Apparently I use import\_role exclusively 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 17, 2024, 5:25pm UTC](https://forum.ansible.com/t/using-become-true-for-a-specific-role/10391/7 "2024-11-17T17:25:47Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
