Use home directory is not created for a non-system account

Hi,

I am getting a really weird error with chef. I have a recpie which looks like:

user 'sysadmin' do
      comment 'The normal user to login to the system with - has sudoers rights.'
      home '/home/sysadmin'
      shell '/bin/bash'
      password '<pass-hash>'
end

When the node is bootstrapped, we see:

 * linux_user[sysadmin] action create[2016-09-15T09:33:34+00:00] INFO: Processing linux_user[sysadmin] action create (dexdyne::users line 2)
[2016-09-15T09:33:34+00:00] DEBUG: Providers for generic linux_user resource enabled on node include: [Chef::Provider::User::Linux]
[2016-09-15T09:33:34+00:00] DEBUG: Provider for action create on resource linux_user[sysadmin] is Chef::Provider::User::Linux
[2016-09-15T09:33:34+00:00] DEBUG: linux_user[sysadmin] user does not exist
DEBUG: received packet nr 1507 type 94 len 300
INFO: channel_data: 0 273b
[2016-09-15T09:33:34+00:00] INFO: linux_user[sysadmin] created
 
     - create user sysadmin

Which, to me, looks as though it is completing successfully. However, when I login, I see the message:

Could not chdir to home directory /home/sysadmin: No such file or directory

And sure enough, with a ls -lah /home/ I get:

-bash-4.2$ sudo ls -lah /home/
[sudo] password for sysadmin: 
total 16K
drwxr-xr-x.  7 root     root         81 Sep 15 09:38 .
dr-xr-xr-x. 17 root     root       4.0K Aug  3 20:10 ..
drwxr-xr-x. 22 root     root       4.0K Sep 15 10:13 enterprise
drwxr-xr-x.  3 mhann    mhann        70 Sep 15 09:30 mhann
drwxr-xr-x. 11 root     root       4.0K Sep 15 09:38 middleware
drwxrwxr-x.  3 postgres enterprise   19 Sep 15 09:38 postgres
drwxrwxr-x.  3 root     enterprise 4.0K Sep 15 09:38 Scripts
-bash-4.2$

The script creates the sysadmin user successfully, and sets the password, but does not create the home directory. I see that there are topics around regarding system users, however, this user is not a system user so it should create the home directory automatically?

Furthermore, this recpie used to work, and now it has stopped, I cannot think of what I may have done to have broken it as I have not touched this recipe since it was originally written.

I can see no error in the output so am unsure of where to go from here to narrow down the issue and was hoping that someone here could provide some assistance.

Thanks in advance,
Marcus

You need to set the user resource option manage_home to be true. Otherwise, it’s like running “useradd” without the “-m” parameter.

https://docs.chef.io/resource_user.html#properties

Nathan Clemons
DevOps Engineer
Moxie Cloud Services (MCS)

O +1.425.467.5075
M +1.360.861.6291
E nclemons@gomoxie.com
W www.gomoxie.comhttp://www.gomoxie.com/

Thanks @nclemons,

Setting manage_home worked. Did something change recently to cause this change as the recipe has been working absolutely fine until today (maybe the default value changed)?

I see that there is a recent commit with the message:

fix the behavior of the linux user provider to implement
manage_home behavior correctly.

Maybe this update caused the issue to just start happening?

Thanks,
Marcus