Using Azure Linux, the disks (OS/Temp) doesn't always get greated in same order as /dev/sda, /dev/sdb. Sometimes if we add a data disk it creates in order like /dev/sda to OS and /dev/sdc to Temp assigning data disk to /dev/sdb. To find the unused disk and mount to the needed partition, I"m trying to create below chef script.
ruby_block "Get First Data Disk" do
block do
s = shell_out("readlink -f $(ls /dev/disk/azure/scsi1/l*)|head -n 1")
node.default['data_mount'] = s.stdout
end
end
bash 'Formats data disks' do
code lazy { "mkfs.ext4 -F #{node['data_mount']}" }
end
mount node['app_data_dir'] do
device lazy { node['data_mount'] }
fstype 'ext4'
action %i[mount enable] # :mount does the initial mount while :enable adds it to fstab
end
I'm testing using chef-client -o...... Regardless, I'm getting error during converge saying /dev/sdb not found and getting error like below. The first two resources were good and successful.
mount("/eng/data/application") do
action [:mount, :enable]
supports {:remount=>false}
retries 0
retry_delay 2
default_guard_interpreter :default
mount_point "/eng/data/application"
device #Chef::DelayedEvaluator:0x00000000017443b0@/opt/local-mode-cache/cache/cookbooks/zzzzzzzzzzzzzzz/recipes/test.rb:13
device_type :device
fsck_device "-"
fstype "ext4"
options ["defaults"]
dump 0
pass 2
username nil
password nil
domain nil
declared_type :mount
cookbook_name "zzzzzzzzzzzzzzz"
recipe_name "test"
end
..................................................had an error: Chef::Exceptions::Mount: Device /dev/sdb
does not exist
[2020-07-28T02:07:22+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Struggling with CHEF compile/Converge for long to setup. Any help here is very useful and appreciated.