Chef Users资源(检查是否存在?) [英] Chef Users resource (check if exists?)
问题描述
我知道如何创建用户资源:
I know how to create a user resource:
user "random" do
supports :manage_home => true
comment "Random User"
uid 1234
gid "users"
home "/home/random"
shell "/bin/bash"
password "$1$JJsvHslV$szsCjVEroftprNn4JHtDi."
end
但是我不确定如何使用Chef查找所有用户的列表在当前节点上。我查看了在厨师客户机运行期间检查node [:users]的情况,但是只有node [:current_user]对我可用。在厨师食谱中,有没有办法询问普通用户是否存在?
But I'm unsure how to use Chef to find a list of all users on a current node. I looked at inspecting node[:users] during a chef-client run, but only node[:current_user] is available to me. Is there a way, in a Chef recipe, to ask if a regular user exists?
我处在不应该/不能创建用户的情况下(由于公司规定,但除非xyz用户已经存在,否则我绝对不应该继续安装本食谱中定义的其他内容。)
I'm in a situation where I shouldn't/can't create users (due to company regulations, but I definitely shouldn't proceed with the installation of other things defined in my cookbook unless xyz users already exist.)
推荐答案
Ohai为您查询系统上的用户:
Ohai queries the users on the system for you:
if node['etc']['passwd']['random']
# Do deploy
end
这篇关于Chef Users资源(检查是否存在?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!