# Two remote users one for production and one from staging

**URL:** <https://forum.ansible.com/t/two-remote-users-one-for-production-and-one-from-staging/15262>\
**Category:** Ansible Project\
**Tags:** ubuntu, aws\
**Created:** [May 18, 2014, 5:44am UTC](https://forum.ansible.com/t/two-remote-users-one-for-production-and-one-from-staging/15262 "2014-05-18T05:44:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![raul\_rodriguez](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@raul\_rodriguez](https://forum.ansible.com/u/raul_rodriguez)\
**Post date:** [May 18, 2014, 5:44am UTC](https://forum.ansible.com/t/two-remote-users-one-for-production-and-one-from-staging/15262/1 "2014-05-18T05:44:29Z")

</div>

Hi there,

I’ve been playing with ansible for the last month, and now I finally have the opportunity to provision our small cluster with it.  
Bye bye puppet.

So far the instructions are pretty clear. But I have some questions on best practices.  
I’m following the directory layout from best practice docs and it looks great.

However, I’m still unsure how can I reuse the playbook for development and production and not duplicating code

I’m using vagrant for dev and aws for production  
So when using vagrant it’s easy to create a new user and do all the stuff using ‘vagrant’ user, then I create our universal user.

However, I’m finding a bit difficult to reuse the same playbook for provisioning aws ec2.  
Since I have to change a different remote user: ubuntu and add the same universal user. Can I create a variable that changes based on the context that is run?  
Where can I find that info?

`

- name: Webserver with MySQL Client, Nginx, and PHP-FPM  
hosts: webservers  
remote\_user: vagrant  
sudo: yes

# how can I load ubuntu when running on production?

roles:

- user
- common
- mysql-client
- nginx
- php-fpm

`

`

#production ec2  
[webservers]  
[machine1.production.com](http://machine1.production.com)  
[machine2.production.com](http://machine2.production.com)

`

`

#dev/stage with vagrant  
[webservers]  
machine1.lo  
machine2.lo

[dbservers]  
mysql1.lo

`

Finally is it possible, after the universal user has been added, to logout and re-connect with this user and resume the remaining tasks

Thanks

---

<div class="post-metadata">

**Author:** ![Antonio\_Marin](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@Antonio\_Marin](https://forum.ansible.com/u/Antonio_Marin)\
**Post date:** [May 18, 2014, 11:40am UTC](https://forum.ansible.com/t/two-remote-users-one-for-production-and-one-from-staging/15262/2 "2014-05-18T11:40:41Z")

</div>

Hi,

For the variables to specify the user of each host, take a look at the documentation: [http://docs.ansible.com/intro\_inventory.html](http://docs.ansible.com/intro_inventory.html)

ansible\_ssh\_user is what you are looking for.

Regarding resuming after the first step, I use a bootstrap playbook that aligns all the managed servers (you run it just once per machine) so there is no need to resume after.  
If you still want the resume behavior, you can try to overwrite the variable during the playbook execution. You can take a look at the docs on how to add variables to the facts. If I recall well, it should be on the module dev section.

Br,  
Tony

> **(attachments)**
>
> ![email_smslogo.png](https://us1.discourse-cdn.com/ansible/original/2X/b/bf3e6c6449d4dec753826c49c05d006b991d5909.png)  
> ![email_icon_phone.png](https://us1.discourse-cdn.com/ansible/original/2X/b/b74cd524dbbf0e00b6a3785174947431b0201bac.png)  
> ![email_icon_skype.png](https://us1.discourse-cdn.com/ansible/original/2X/e/e823c7e1a55292a1f987d45940679ebd0be5270c.png)  
> ![email_icon_location.png](https://us1.discourse-cdn.com/ansible/original/2X/3/338e299801b9a07a4c7900163a9772f30da0a261.png)  
> ![email_icon_email.png](https://us1.discourse-cdn.com/ansible/original/2X/4/46940bb242ccbb82b87bd8e8f1749e2430b0c148.png)  
> ![email_icon_linkedin.png](https://us1.discourse-cdn.com/ansible/original/2X/c/ca838365667d8197fc713b2d1e1c59bf98a0871c.png)  
> ![email_icon_website.png](https://us1.discourse-cdn.com/ansible/original/2X/5/5c81c3c6ff3c344a10d980a674d7ef9d98002b77.png)
