# Revision history [back]

You don't need to check for existence of the link, you just need to write your code like this:

$filelist = [$abc, "${abc}/file", "${def}/file" ]
file { $filelist: ensure => absent, }  Add more files to that list that you want to ensure are deleted. Remember always that your Puppet code defines the desired state of the machine. Therefore, you have to write Puppet code to transform your machine from its current state to the desired state. Once you do that, Puppet will continue to keep that machine in the desired state every time the agent runs. You don't need to check for existence of the link, you just need to write your code like this: $filelist = [ $abc, "${abc}/file", "${def}/file" ] file {$filelist:
ensure => absent,
}


Add more files to that list that you want to ensure are deleted.

Remember always that your Puppet code defines the desired state of the machine. Therefore, you have to write Puppet code to transform your machine from its current state to the desired state. Once you do that, Puppet will continue to keep that machine in the desired state every time the agent runs.

UPDATE:

Since you are using the tidy resource, you have to make sure that you pass the recurse and rmdirs attribute, like so:

tidy { $abc: recurse => true, rmdirs => true, }  Assuming $abc contains directory path, that tidy resource will remove all files and directories within the directory, then remove the directory itself.