Knowing if a file is managed by puppet

5,338 views
Skip to first unread message

chaica

unread,
Nov 15, 2011, 5:38:52 AM11/15/11
to Puppet Users
Hi,

I'm looking for a simple way to check if a file on a client (where
puppetd is running) is managed by puppet. At this time, I have to put
a comment on the file and have to run a puppetd -to --noop in order to
see if puppet triggers actions on this file. Is there any way to
simply find if a file on the client is supervised by puppet ?

Regards,
Carl Chenet

R.I.Pienaar

unread,
Nov 15, 2011, 11:04:59 AM11/15/11
to puppet...@googlegroups.com

I wrote https://github.com/ripienaar/puppet-parselocalconfig some time
ago that can do this on the node - I am not sure if it still works with
latest puppet version but worth a try

DEGREMONT Aurelien

unread,
Nov 15, 2011, 11:08:14 AM11/15/11
to puppet...@googlegroups.com
R.I.Pienaar a �crit :

> I wrote https://github.com/ripienaar/puppet-parselocalconfig some time
> ago that can do this on the node - I am not sure if it still works with
> latest puppet version but worth a try
>
>
We are using a modified version of this script and it is mandatory for us.
I do not know how to work with Puppet if you do not have an easy way to
know which resources are managed by puppet or not.

The only other solution if to do some kind of 'grep -r "my_object"
/etc/puppet/* ' which is very unfriendly for admins...

Aur�lien


Nan Liu

unread,
Nov 15, 2011, 11:14:42 AM11/15/11
to puppet...@googlegroups.com

In Puppet 2.7 you can issue the command:
puppet catalog select $hostname $type

So say if you had a system called prod_db and you are interested in
all the file resources puppet manage:
puppet catalog select prod_db file

To list all the services managed by puppet on that system:
puppet catalog select prod_db service

This currently only shows the resource title so it can be improved.
This is one of the improvements with Puppet 2.7 faces where the
catalog information is better exposed to the end user.

Thanks,

Nan

Nigel Kersten

unread,
Nov 15, 2011, 11:22:57 AM11/15/11
to puppet...@googlegroups.com
On Tue, Nov 15, 2011 at 8:14 AM, Nan Liu <n...@puppetlabs.com> wrote:
> On Tue, Nov 15, 2011 at 5:38 AM, chaica <lordc...@free.fr> wrote:
>> I'm looking for a simple way to check if a file on a client (where
>> puppetd is running) is managed by puppet. At this time, I have to put
>> a comment on the file and have to run a puppetd -to --noop in order to
>> see if puppet triggers actions on this file. Is there any way to
>> simply find if a file on the client is supervised by puppet ?
>
> In Puppet 2.7 you can issue the command:
> puppet catalog select $hostname $type

Also as of 2.7.6, we automatically dump this info in a text file on the agents.

cat $(puppet agent --configprint resourcefile)

file[/etc/puppetlabs/mcollective/ssl/mcollective-private.pem]
file[/opt/puppet/libexec/mcollective/mcollective/agent/package.rb]
file[/etc/puppetlabs/activemq/broker.p12]
file[/etc/puppetlabs/activemq/broker.ts]
file[/etc/puppetlabs/mcollective/ssl/mcollective-cert.pem]
file[/opt/puppet/share/puppet-dashboard/.ssh/authorized_keys]
file[/var/lib/peadmin/.mcollective.d/peadmin-private.pem]
file[/opt/puppet/libexec/mcollective/mcollective/registration/meta.rb]
file[/opt/puppet/libexec/mcollective/mcollective/util]
file[/etc/puppetlabs/mcollective/ssl/clients/mcollective-public.pem]
group[peadmin]
user[peadmin]
...

Vince Taluskie

unread,
Nov 15, 2011, 11:25:27 AM11/15/11
to puppet...@googlegroups.com
I'm using the puppet-ls script for this purpose.

https://github.com/deanwilson/puppet-scripts/blob/master/puppet-ls

vince

> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>
>

Ken Barber

unread,
Nov 15, 2011, 12:03:43 PM11/15/11
to puppet...@googlegroups.com
Depends on why you want this info ... but its available in the catalog
on the box for 'grepping' (more or less).

Something I recommend to some people:

http://www.tenshu.net/2010/08/adventures-in-puppet-tangled-strings.html

Which does more or less that ... but shows a banner in VIM for users
to warn them the file is puppet managed before they modify it.

ken.

Iain Sutton

unread,
Nov 15, 2011, 6:39:00 PM11/15/11
to puppet...@googlegroups.com
+1 for tangled strings

Daniel Maher

unread,
Nov 16, 2011, 4:53:01 AM11/16/11
to puppet...@googlegroups.com
On 11/16/2011 12:39 AM, Iain Sutton wrote:
> +1 for tangled strings
>
> On 16 November 2011 04:03, Ken Barber <k...@puppetlabs.com
> <mailto:k...@puppetlabs.com>> wrote:
>
> Depends on why you want this info ... but its available in the catalog
> on the box for 'grepping' (more or less).
>
> Something I recommend to some people:
>
> http://www.tenshu.net/2010/08/adventures-in-puppet-tangled-strings.html
>
> Which does more or less that ... but shows a banner in VIM for users
> to warn them the file is puppet managed before they modify it.

A mild word of warning: tangledstrings is distributed as a Vimball,
which works well in (most? all?) Linux flavours of Vim, but you may run
into support problems in other OS's (such as OpenBSD, *grumble grumble*).

That said, tangledstrings does exactly what it's supposed to do: act as
a very handy warning layer.

--
Daniel Maher

With listening comes wisdom, with speaking repentance.

Reply all
Reply to author
Forward
0 new messages