How to check if a directory is a symlink in a chef

I just want to delete the directory if it is not symlnik.

directory "/var/www/html/" do
  action :delete
  only_if ???
end
+4
source share
2 answers

The selected answer will not work on Windows or systems where Bash is the default interpreter. You should use a cross-platform Ruby solution (and faster, since there is no process there):

directory '/var/www/html' do
  action :delete
  not_if { File.symlink?('/var/www/html') }
end
+9
source

What about:

directory "/var/www/html/" do
    action :delete
    not_if "test -L /var/www/html/"
end

test -L $filereturns 0 (true) if it $fileis a symbolic link.

+1
source

Source: https://habr.com/ru/post/1535231/


All Articles