2

Having some trouble with the user module in Ansible. Everything is technically working, just not as I expected. It seems Ansible uses "useradd" versus the newer "adduser" in Ubuntu and I think its missing some configuration settings when creating users. If I let Ansible create the user, the account is created and active but the account behaves a bit strangely. In particualar, the user@hostname prompt is not present. I did confirm that it is using /bin/bash. All I get as a prompt for Ansible created users is $. Doesnt even display current working directory. I want to use Ansible to create the admin accounts, but not if its going to behave like this. If however I create the user manually using adduser in the OS, the account gets setup as expected. Any thoughts?

Ansible user prompt:

$

Manual user created prompt:

username@hostname:directory$

Here is an example user portion of the playbook:

- name: Add user
  user:
    name: Username
    password: 'Password Hash'
    groups: sudo
    state: present
Atomiklan
  • 539
  • 7
  • 16
  • Also, when creating system user, useradd (hence ansible user module) create UID beginning at 1000 and counting backwards. On the other hand, "adduser" create system user with UID beginning at 100. They both create non-system user UID beginning at 1000. Same behaviour with the ansible Group module – megar Oct 02 '20 at 08:24
  • Aside: `useradd` is the standard tool for adding users. `adduser` is a Debian-specific script and should not be relied on for cross-distribution compatibility. Like many questionable things Debian does, it's probably best avoided. – Michael Hampton Oct 02 '20 at 15:27

1 Answers1

5

You are probably need to add the skeleton option that copies /etc/skel which includes all of the standard shell profiles and so on.

Zoredache
  • 128,755
  • 40
  • 271
  • 413