我阅读了此https://docs.chef.io/resource_user.html,看起来这是用于创建系统帐户。但是我想为没有登录选项的运行进程创建一个用户。现在,我在厨师食谱中使用了execute块。但是我不是执行块的忠实粉丝。有什么办法可以代替此代码?
execute 'create user for service' do
command -c "This account is for testing something" -s /sbin/nologin -G 'myGroup' -r my_user'
end
-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
该nologin
可执行文件可以被替换false
。为您的发行版使用找到正确的路径which nologin
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句