# How to create a user before a role is executed

**URL:** <https://forum.ansible.com/t/how-to-create-a-user-before-a-role-is-executed/27876>\
**Category:** Ansible Project\
**Created:** [June 26, 2018, 10:29pm UTC](https://forum.ansible.com/t/how-to-create-a-user-before-a-role-is-executed/27876 "2018-06-26T22:29:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesus\_Gomez](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@Jesus\_Gomez](https://forum.ansible.com/u/Jesus_Gomez)\
**Post date:** [June 26, 2018, 10:29pm UTC](https://forum.ansible.com/t/how-to-create-a-user-before-a-role-is-executed/27876/1 "2018-06-26T22:29:18Z")

</div>

Hello.

I'm trying to use the role `rvm_io.ruby`[1] specifying the variable  
`rvm1_user` to a user that is being created in the same playbook, but  
the provisioning fail because the role is being executed before that  
happen.

I get the following error:

&nbsp;&nbsp;&nbsp;&nbsp;Failed to set permissions on the temporary files Ansible needs to  
create when becoming an unprivileged user (rc: 1, err: chown: invalid  
user: ‘deploy’\n}). For information on working around this, see  
[https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user](https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user)

The user I try to use is called `deploy` (mentioned in the error message).

[1] [https://github.com/rvm/rvm1-ansible](https://github.com/rvm/rvm1-ansible)

---

<div class="post-metadata">

**Author:** ![Jesus\_Gomez](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@Jesus\_Gomez](https://forum.ansible.com/u/Jesus_Gomez)\
**Post date:** [June 27, 2018, 12:10pm UTC](https://forum.ansible.com/t/how-to-create-a-user-before-a-role-is-executed/27876/2 "2018-06-27T12:10:48Z")

</div>

As documented, One can use pre-tasks to write tasks to be executed before any role:

[https://docs.ansible.com/ansible/devel/user\_guide/playbooks\_reuse\_roles.html#using-roles](https://docs.ansible.com/ansible/devel/user_guide/playbooks_reuse_roles.html#using-roles)
