# Handle multiple users inside a playbook

**URL:** <https://forum.ansible.com/t/handle-multiple-users-inside-a-playbook/33993>\
**Category:** Ansible Project\
**Created:** [October 9, 2020, 10:27am UTC](https://forum.ansible.com/t/handle-multiple-users-inside-a-playbook/33993 "2020-10-09T10:27:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniele\_Calzetti](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@Daniele\_Calzetti](https://forum.ansible.com/u/Daniele_Calzetti)\
**Post date:** [October 9, 2020, 10:27am UTC](https://forum.ansible.com/t/handle-multiple-users-inside-a-playbook/33993/1 "2020-10-09T10:27:20Z")

</div>

I have a playbook where I access as user without privigiles, then i become root with become: yes and --ask-become-pass.  
At some point I have few task that require to be executed as another user (apache), for example:

- name: Check if maintenance install is present  
shell: php occ | grep maintenance  
become: yes  
become\_user: apache  
become\_method: sudo  
args:  
chdir: “{{path\_installation}}nextcloud/”  
register: maintenance\_install

I tried to add the regular user to wheel group but it doesn’t work, because I thought that the script would have tried:

- SSH access via regular user (i.e test);
- Detection of the become method and become user indicated in the task
- execution of the task by providing the password used for the regular user (i.e. test).

But it didn’t worked because, I suppose, it uses as become password the one given with --ask-become-password.

Any suggestion? How could I write the script?
