Home directory not created with custom resource added with chef

On the wandering field exact64 (ubuntu 12.04)

When creating a custom resource using a chef, the home directory is not created:

My recipe:

user "myuser" do
  supports :manage_home => true
  shell "/bin/bash"
  home "/home/myuser"
  comment "Created by Chef"
  password "myencryptedpassword"
  system true
  provider Chef::Provider::User::Useradd
  action :create
end

When I authenticate:

$ su - myuser
Password: 
No directory, logging in with HOME=/

Update - workaround for accurate 64 (Ubuntu 12.04 64 bit)

directory "/home/myuser" do
  owner "myuser"
  group "myuser"
  mode 00755
  action :create
end
+4
source share
3 answers

While users of the system usually do not have a home directory, the chef will create a home directory even for users of the system, if you specify home. I tried this and cannot reproduce the problem.

What happens is a little hidden in the documentation. The chef's docs say:

| . useradd , -r useradd.

man- useradd:

-r, --system
     Create a system account.

   System users will be created with no aging information in /etc/shadow, 
   and their numeric identifiers are chosen in the SYS_UID_MIN-SYS_UID_MAX
   range, defined in >/etc/login.defs, instead of UID_MIN-UID_MAX 
   (and their GID counterparts for the creation of groups).

   Note that useradd will not create a home directory for such an user,
   regardless of the default setting in /etc/login.defs (CREATE_HOME). 
   You have to specify the -m options if you want a home directory for
   a system account to be created.

, , - -m , . .

+3

, ? , : manage_home home , , . , .

, useradd , , -m , , , useradd - .

+1

. - . "[homedir] , CREATE_HOME /etc/login.defs ". Ubuntu . , , .

/etc/login.defs :

CREATE_HOME  yes 

, , - homedir, homedir. , homedirs .

+1

Source: https://habr.com/ru/post/1540373/


All Articles