i would write the users and their info in 1 file users.py:

allusers;
    username:
          uid: 123
          fullname: ....
   username2:
          uid: 321
          ....


and then for each host just list the users that have access, either in
host_vars/hostname.yml:

myusers:
 - username
 - username1

or inline in the ini file:

hotname myusers=[ 'username', 'username1']

then in the user creation task:

- users: uid={{allusers[item].uid}} ....
  with_items: "{{myusers}}"

There are other ways, but this seems to me easiest for you.

On Fri, Sep 4, 2015 at 4:09 PM, T N <trr...@gmail.com> wrote:
> Hi,
>
> Can't find an answer to this.
>
> The Ansible documents talk about "How do I handle different machines needing
> different user accounts or ports to log in with?", and other things, but I
> can't see how to address what we're trying to do from the information and
> zillions of searches I've done on Google and this list.
>
> I'm open to different ways of doing it, but ideally (I guess), I'd like to
> have a single file that lists all our hosts, and for each host, lists the
> login names (in addition to the "stock" login names) that should be on that
> machine.  From that list, I'd like ansible to pull in the remaining user
> information to create the account (uid, primary gid, shell, comment, home
> directory, possibly a password), and then make sure the user's account is on
> the machine.
>
> I have gotten Ansible so that users common to all hosts are added.  That
> works fine.
>
> But how do I call the user module per host to have it add a list of
> additional users that are unique to that machine- ie. the users who have
> accounts on some machines and not others?
>
> There is no grouping (eg. "web servers") that this can be subsumed under in
> our environment.
>
> This seems like a simple task but it isn't obvious to me how to do it- at
> least not elegantly (especially in a way that's dry).
>
> Thanks in advance,
>
> T N
>
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d6967b14-007c-4483-b2ea-6a05826fc60c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Brian Coca

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJ5XC8m1gAqgsq1gHB80wY54NiFUaTN%3DS9vHSNtzjrg9sU26nQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to