Using become: True for a specific role

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 :wink:
I made several tests, here is one of them:

[...]
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

Apparently it was a bug in Ansible version 2.4 issue 35065 but I’m using the version 2.27.4.

Has anyone more infos about that?

You probably mean version 2.17.4?

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

instead of this, wouldn’t it be:

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

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.

Ahh, that is the distinction. Apparently I use import_role exclusively :slight_smile: