如何检查目录是否为chef中的符号链接

mor*_*ter 6 shell chef-infra

如果它不是symlnik,我只想删除目录.

directory "/var/www/html/" do
  action :delete
  only_if ???
end
Run Code Online (Sandbox Code Playgroud)

set*_*rgo 12

所选答案不适用于Windows或Bash是默认解释器的系统.您应该使用Ruby解决方案来实现跨平台(并且更快,因为没有进程生成):

directory '/var/www/html' do
  action :delete
  not_if { File.symlink?('/var/www/html') }
end
Run Code Online (Sandbox Code Playgroud)