I have a requirement to ensure that /home/someuser/.ssh is empty at the start of an initialization. It can be removed completely What is the Puppet way to ensure a directory is empty prior to it being created? I''m looking for something like: file { "/home/someuser/.ssh": ensure => present-but-recreate-if-existing } -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/032e9b36-c534-4a70-8824-961f7bc6173b%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Mon, Nov 25, 2013 at 12:31 PM, Stuart Cracraft <smcracraft@gmail.com> wrote:> I''m looking for something like: > > file { "/home/someuser/.ssh": > ensure => present-but-recreate-if-existing > }Well, you still want ensure => directory. But take a look at the purge param: http://docs.puppetlabs.com/references/latest/type.html#file -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAEUKkZ-F0yVOux2wM-%3DrJv%2BVdOf0FAOkdAnW6qYYC123cpeiJA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
The purge feature looks a little extreme. It continues to delete files in the managed area not controlled by Puppet. I am looking for just a "first-time wipe-the-slate-clean" before it creates it as an empty directory, possibly populates it with a few files, and for now, doesn''t try to manage the constituent pieces in /home/someuser/.ssh. On Monday, November 25, 2013 10:31:34 AM UTC-8, Stuart Cracraft wrote:> I have a requirement to ensure that /home/someuser/.ssh is empty > at the start of an initialization. It can be removed completely > > What is the Puppet way to ensure a directory is empty prior to it > being created? > > I''m looking for something like: > > file { "/home/someuser/.ssh": > ensure => present-but-recreate-if-existing > } > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/db34c06a-abe0-46d4-9b20-1b2f2c0d10f5%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Hi, your request is problematic insofar that it does not match the puppet philosophy very well. Puppet expects you to define a state you desire. The details of how this state can be reached should be up to puppet. That''s idealized of course, and in the real world, there are plenty examples of both concepts blending into each other. One of the best tools for this is indeed the exec resource. If you have a class manage_directory to handle the directory in question, think: exec { "clean-directory": command => ..., before => Class["manage_directory"], } However, there''s a new problem: Puppet has no way to know if this is expected to be done and *will* perform the exec on every run. This might be a workaround: exec { "clean-directory": command => ..., before => Class["manage_directory"], creates => "/path/to/directory/.puppet-managed", } Then in your manage_directory class, make sure the .puppet-managed file is created. This will keep puppet from performing the cleanup exec again. Note that this sort of code requires gratuitous documentation, because it is extremely unobvious what''s happening and why. If given any choice, I''d prefer to implement such "pre-puppet cleanup" outside of puppet altogether. HTH, Felix On 11/25/2013 10:07 PM, Stuart Cracraft wrote:> The purge feature looks a little extreme. > > It continues to delete files in the managed area not controlled by Puppet. > > I am looking for just a "first-time wipe-the-slate-clean" before it > creates it > as an empty directory, possibly populates it with a few files, and for now, > doesn''t try to manage the constituent pieces in /home/someuser/.ssh. > > On Monday, November 25, 2013 10:31:34 AM UTC-8, Stuart Cracraft wrote: > > I have a requirement to ensure that /home/someuser/.ssh is empty > at the start of an initialization. It can be removed completely > > What is the Puppet way to ensure a directory is empty prior to it > being created? > > I''m looking for something like: > > file { "/home/someuser/.ssh": > ensure => present-but-recreate-if-existing > }-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/5294B0CD.2050607%40alumni.tu-berlin.de. For more options, visit https://groups.google.com/groups/opt_out.