我正在通過廚師創建一個用戶。他的屬性存儲在數據包:廚師有條件的資源參數
{
"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
我怎樣才能做到這一點?
是否安裝了帶有軟件包資源的zsh不是一個選項? – Tensibai
@Tensibai,好吧,實際上我使用該食譜來安裝'zsh'。我只是不想依賴它。 – madhead
在這種情況下,@mudasobwa答案是正確的(如果答案中包含了一個關於ruby代碼如何適用於未來讀者的小解釋,我已經投了贊成票) – Tensibai