Request for help in creating a new user

20 views
Skip to first unread message

xuxu

unread,
Nov 29, 2014, 3:06:07 PM11/29/14
to ansible...@googlegroups.com
This is what my playbook looks like:
---

- hosts: ec2
  user: root
  roles:
    - createuser

- hosts: ec2
  user: winery
  roles:
    - winery

The task for createuser looks like this:

---

- name: create user for given app
  user: name=winery

The first task works as expected, but then it can't continue on as the user "winery", because it doesn't have sufficient privileges to login to the server as that user. 

How do you continue on from here? 

Can I upload an SSL key for the user so that I can login without problems?

If the root and the new user both have the same SSL key, that seems wrong, what would be suggested if it is in appropriate to do this?

It seems silly to create a user using a "createuser" role, is there a way to get around this? I was just using user:root with remote_user: winery attached to every command, but that didn't seem right either.

I really hope somebody responds!

Mehul Ved

unread,
Nov 30, 2014, 1:03:31 PM11/30/14
to ansible...@googlegroups.com
On Sun, Nov 30, 2014 at 1:36 AM, xuxu <xiu...@gmail.com> wrote:
> This is what my playbook looks like:
> ---
>
> - hosts: ec2
> user: root
> roles:
> - createuser
>
> - hosts: ec2
> user: winery
> roles:
> - winery
>
> The task for createuser looks like this:
>
> ---
>
> - name: create user for given app
> user: name=winery
>
> The first task works as expected, but then it can't continue on as the user
> "winery", because it doesn't have sufficient privileges to login to the
> server as that user.
>
> How do you continue on from here?
>
> Can I upload an SSL key for the user so that I can login without problems?

How about using the authorized_key module
http://docs.ansible.com/authorized_key_module.html
It has an option to specify which user to add the key to.
Reply all
Reply to author
Forward
0 new messages