我读了这个https://docs.chef.io/resource_user.html,看起来这是用于创建系统帐户.但我想创建一个用户运行进程没有登录选项.现在,我在我的厨师食谱中使用了执行块.但我不是执行块的忠实粉丝.有什么办法可以替换这段代码吗?
execute 'create user for service' do
command -c "This account is for testing something" -s /sbin/nologin -G 'myGroup' -r my_user'
end
Run Code Online (Sandbox Code Playgroud)
-s /sbin/nologin您的命令与shell "/sbin/nologin"在用户资源中指定相同.
该user资源是创建用户,如果你设置了它会创建一个系统用户system属性true.
所以user命令行的Chef 资源是:
user 'my_user' do # the user name in your command
action :create # default action, could be omitted, but better to precise it
shell '/sbin/nologin'
gid 'myGroup' # the -G in your execute
comment 'This account is for testing somethin' # the -c in your execute
system true # to match your -r in execute
manage_home false # to avoid creating a home directory, omit if you wish it anyway
end
Run Code Online (Sandbox Code Playgroud)
该nologin可执行文件可以被替换false.为您的发行版使用找到正确的路径which nologin.