我创建通过厨师的用户。 他的属性存储在数据包:
{
"id": "developer",
"home": "/home/developer",
"shell": "/bin/zsh",
"password": "s3cr3t"
}
配方是:
developer = data_bag_item('users', 'developer')
user developer['id'] do
action :create
supports :manage_home => true
home developer['home']
comment developer['comment']
shell developer['shell']
password developer['password']
end
问题是,如果zsh
节点上没有安装,我无法登录的developer
。 所以,我希望有条件申请论据user
资源,如:
user developer['id'] do
action :create
supports :manage_home => true
home developer['home']
comment developer['comment']
if installed?(developer['shell'])
shell developer['shell']
end
password developer['password']
end
我怎样才能做到这一点?