Ask Your Question

How do I remove a file after defining it in manifest?

asked 2015-03-21 07:03:54 -0600

RobinFTW gravatar image

I am quite new to Puppet, and am trying my hand at creating my own modules. One of those modules creates an Apache virtual host, and a folder to go with it. Now, when I remove the definition from my manifest, I want it to remove the folder too. Is this possible? the puppetlabs-apache module seems to be doing that, but I don't see how.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-21 14:29:41 -0600

ramindk gravatar image

Nearly all Puppet modules use a variation of this technique.

class rsyslogs::config { 

  file { '/etc/rsyslog.d/':
    ensure  => directory,
    force   => true,
    purge   => true,
    recurse => true,
    notify => Service['rsyslog'],

By setting purge on a directory Puppet will automatically remove any file in the directory that is not in the current catalog. In the example above any purges done by the directory would also notify Puppet to restart the rsyslog service.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-03-21 07:03:54 -0600

Seen: 599 times

Last updated: Mar 21 '15