Tyipcially you wouldn't create different host records just to connect to them as different users, but would specify this as "-u" to the playbook execution.
And while you can keep variables inline with ":vars", I would generally recommend group_vars/ and host_vars/ files for nearly everyone, they are cleaner and can also help represent structured data. It's definitely fine to set ansible_ssh_user there, but having hte "-user" as part of the host name is a bit unusual. Also if you have different environments that are not managed together, I usually recommend seperate inventory files for them, keeps it simpler in most cases. On Wed, Mar 5, 2014 at 10:53 PM, Aleksey Maksimov <[email protected]>wrote: > Hi, > > I am just starting with Ansible and have questions on how to better > structure my inventory file(s). > > Here is what I have: > > Multiple hosts, assigned to different environments. > > test1 -> host1, host2, host3 > test2 -> host4, host5, host6 > > On each of those hosts I have multiple users, that used to run various > software components and such users have to be configured differently. > > I've put this to inventory like this: > > [test1-host1] > test1-host1-user1 ansible_ssh_user=user1 > test1-host1-user2 ansible_ssh_user=user2 > > [test1-host1:vars] > ansible_ssh_host=host1_name > > [test1-host2] > test1-host2-user3 ansible_ssh_user=user3 > test1-host2-user4 ansible_ssh_user=user4 > > [test1-host2] > ansible_ssh_host=host2_name > > Am I doing my inventory right? > > Regards, > Aleksey Maksimov > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/d95c5f06-26ff-4957-b3af-f0deac330f03%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/d95c5f06-26ff-4957-b3af-f0deac330f03%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEVJ8QPT7f0BjwEpFs-k1Rn2YvwZ-XzmMAwHB%2BaUozNpa2CZQg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
