Search code examples
puppet

Puppet: how to remove a directory and everything in it


I'm sure this is really simple, but I cannot work it out.

I want to delete the directory C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1. My attempts thus far have managed to remove everything inside the directory 1.0.0.1, but I can't work out how to remove the actual directory.

I did think about going up a level, but that would mean that when I copy across the new version of this module (2.2.5), on the next run, Puppet will delete it.

Here are my two attempts:

file resource

file { "${modules_path}/PowerShellGet/1.0.0.1" :
  ensure  => directory,
  recurse => true,
  purge   => true,
  force   => true,
}

tidy resource

tidy { "${modules_path}/PowerShellGet/1.0.0.1" :
  age     => 0,
  recurse => true,
  rmdirs  => true,
}

T.I.A


Solution

  • Try it like this:

    file { "${modules_path}/PowerShellGet/1.0.0.1" :
      ensure  => absent,
      recurse => true,
      force   => true,
    }