0
我們有一對廚師配方,有幾個資源區塊。第一個資源塊位於bash中,並獲取邏輯卷的UUID的值並存儲到變量$ uuid中。如何在同一配方的廚師資源區塊之間傳遞變量
# Get UUID value
bash 'get uuid' do
cwd "/"
code <<-EOH
uuid=$(blkid -o value -s UUID /dev/vg_volgroup/lv_logicalvolume)
EOH
end
我們需要的變量$uuid
傳遞給我們的第二個資源區塊:
# Mount directory, format, update fstab
mount node['mount_dir'] do
dump 1
pass 2
device #{uuid}
device_type :uuid
fstype node['fstype']
options node['options']
action [ :mount, :enable]
end
不幸的是,這是行不通的。 $ uuid的值不會傳入第二個資源塊。
是否有更合適的方法來從第二個資源塊中引用$ uuid?我甚至可能問什麼?
謝謝Szymon。我最終使用Ohai如下並完美地工作:'device node ['filesystem2'] ['by_device'] ['/ dev/mapper/vg_volgroup-lv_logicalvolume'] ['uuid']' – Keith