Any way to have puppet notify me if any files are missing from a directory?

203 views
Skip to first unread message

Dan Pasacrita

unread,
Apr 25, 2014, 10:22:24 AM4/25/14
to puppet...@googlegroups.com
Hey everyone, first I want to say that I joined this community a few days ago and already you guys have been amazingly helpful.

One thing that's been puzzling me lately is how I can have puppet examine a directory, compare its contents against a source, but only notify you if anything is missing. I know I can have it automatically sync the contents with the following:

file { '/path/to/file':
                ensure => "directory",
                recurse => "remote",
                mode => 755,
                source => "/path/to/source",
}

But is there any way for it to just check the directory, and not move anything over? Maybe it can run an exec command if it doesn't find every file that it needs to? One thing I was looking at was the creates parameter, like this:

exec { "/bin/echo absent >> /home/dpasacrita/absent.txt ":
                creates => "/home/user_name/test_dir",
}

which will create a text file if the directory "test_dir" is absent. This works, but it can't check the contents, since there's no source to compare them to. So I don't think that's the right way to go about it.

Any ideas? 

Felix Frank

unread,
Apr 25, 2014, 10:42:38 AM4/25/14
to puppet...@googlegroups.com
Hi,

On 04/25/2014 04:22 PM, Dan Pasacrita wrote:
> file { '/path/to/file':
> ensure => "directory",
> recurse => "remote",
> mode => 755,
> source => "/path/to/source",
> }
>
> But is there any way for it to /just/ check the directory, and not move
> anything over?

if you omit the 'source' parameter, Puppet will indeed only make sure
that the path in question does lead to a directory, create it if it is
missing (provided the parent directory does exist) or even change an
existing file/symlink into a directory (danger, Will Robinson).

HTH,
Felix

José Luis Ledesma

unread,
Apr 25, 2014, 10:54:08 AM4/25/14
to puppet...@googlegroups.com

You can use the noop parameter to avoid modifications, and the tagmail feature to receive an email notification just for this resource.

Regards,

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7d2d3710-f2b6-41b2-88c5-dbeb53fff820%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Pasacrita

unread,
Apr 25, 2014, 2:31:10 PM4/25/14
to puppet...@googlegroups.com
Thanks dude, noop was exactly what I was looking for. I'm wondering why the Documentation doesn't point out this feature more, because I don't recall ever seeing it.


--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/DRdAGS4Xir8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAF_B3de4r29wWXs423Lx7EyMY%3DKrh4tERPTO7VwPSpJiDsuswg%40mail.gmail.com.

José Luis Ledesma

unread,
Apr 25, 2014, 2:41:54 PM4/25/14
to puppet...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages