主目录不是通过使用Chef添加用户资源来创建的 [英] home directory is not created with adding user resource with chef
问题描述
在精确到无用的盒子上(ubuntu 12.04)
On a vagrant box precise64 (ubuntu 12.04)
在使用Chef创建用户资源时,不会创建主目录:
While creating a user resource with Chef, the home directory is not created:
我的食谱:
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
当我进行身份验证时:
$ su - myuser
Password:
No directory, logging in with HOME=/
更新-Precision64(Ubuntu 12.04 64位)的解决方法
Update - The workaround for precise64 (Ubuntu 12.04 64bit)
directory "/home/myuser" do
owner "myuser"
group "myuser"
mode 00755
action :create
end
推荐答案
系统用户通常没有主目录,如果您指定 home
,则厨师甚至会为系统用户创建主目录。我已经尝试过了,无法重现该问题。
While system users usually don't have a home dir, chef will create the home dir even for system users if you specify home
. I've tried it, and cannot reproduce the issue.
正在发生的事情在文档中有些隐藏。 首席文档说:
What is going on is a little bit hidden in the documentation. The chef documentations says:
系统|用于创建系统用户。此属性可以与useradd一起用作提供者,以创建将-r标志传递给useradd的系统用户。
system | Use to create a system user. This attribute may be used with useradd as the provider to create a system user which passes the -r flag to useradd.
看看useradd的手册页:
If have a look at the man page of 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
选项。因此,我无法重现此问题。
However, it seems like chef is passing the -m
option explicitly if you specify a home dir. I could not reproduce this issue therefore.
这篇关于主目录不是通过使用Chef添加用户资源来创建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!