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
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