Identifying file content change in subsequent client run

33 views
Skip to first unread message

ganesh634

unread,
Oct 10, 2014, 1:20:58 AM10/10/14
to puppet...@googlegroups.com


How can i identify if the file content is changed in subsequent client run.
Need this information for new resource implementation, which will take action
only if file contents are modified.
The file will be created on client using template resource.

Is there a way to cache information of previous client run if the client is running in cron mode.


Ashish Jaiswal

unread,
Oct 10, 2014, 1:42:54 AM10/10/14
to puppet...@googlegroups.com, ganesh634
Hi,

You can check for the mtime in file resource.
> --
> 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
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/f8b3cae1-c10f-483c-83e6-aebb664c66f8%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/f8b3cae1-c10f-483c-83e6-aebb664c66f8%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

ganesh634

unread,
Oct 10, 2014, 2:03:44 AM10/10/14
to puppet...@googlegroups.com
Thanks for your reply.
In that case i need to cache the mtime for file and on subsequent client run
need to check if mtime is same or not.
How to cache this information for client running in cron mode.
Is there a way to save context of previous client run.

Ashish Jaiswal

unread,
Oct 10, 2014, 7:04:27 AM10/10/14
to puppet...@googlegroups.com, ganesh634
Hi,

Basically you don't need to cache it, you can store the reports in
puppetdb or in filebucket.

https://docs.puppetlabs.com/references/3.7.latest/type.html#file-attribute-mtime

Or let us know what is your actual goal. You don't want your file to get
change, if change (check mtime) then replace.
> --
> 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
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/489716ef-08f0-4c65-ac7a-224ddf61f5a0%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/489716ef-08f0-4c65-ac7a-224ddf61f5a0%40googlegroups.com?utm_medium=email&utm_source=footer>.

Ganesh Nalawade

unread,
Oct 10, 2014, 7:29:32 AM10/10/14
to Ashish Jaiswal, puppet...@googlegroups.com
The goal it to implement a new resource type that will read the
config file and apply it on device on first client run.

For subsequent client run the apply action should be done only
if the content of config file is changed.


On Fri, Oct 10, 2014 at 4:34 PM, Ashish Jaiswal <ashis...@gmail.com> wrote:
Hi,

Basically you don't need to cache it, you can store the reports in puppetdb or in filebucket.

https://docs.puppetlabs.com/references/3.7.latest/type.html#file-attribute-mtime

Or let us know what is your actual goal. You don't want your file to get change, if change (check mtime) then replace.

On Friday 10 October 2014 11:33 AM, ganesh634 wrote:
Thanks for your reply.
In that case i need to cache the mtime for file and on subsequent client run
need to check if mtime is same or not.
How to cache this information for client running in cron mode.
Is there a way to save context of previous client run.

On Friday, 10 October 2014 10:50:58 UTC+5:30, ganesh634 wrote:



    How can i identify if the file content is changed in subsequent
    client run.
    Need this information for new resource implementation, which will
    take action
    only if file contents are modified.
    The file will be created on client using template resource.

    Is there a way to cache information of previous client run if the
    client is running in cron mode.


--
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 <mailto:puppet-users+unsub...@googlegroups.com>.

jcbollinger

unread,
Oct 10, 2014, 10:58:41 AM10/10/14
to puppet...@googlegroups.com


On Friday, October 10, 2014 6:29:32 AM UTC-5, ganesh634 wrote:
The goal it to implement a new resource type that will read the
config file and apply it on device on first client run.

For subsequent client run the apply action should be done only
if the content of config file is changed.



You are trying to re-invent the wheel.  Puppet already has a facility for resources to be advised when Puppet creates or updates other resources.  It is exposed in the DSL via the 'notify' and 'subscribe' resource metaparameters and the signaling chain operators ~> and <~.  If during a run a resource receives any 'events' from modified resources, then the event recipient is 'refreshed' some time after being brought into sync.  That facility is commonly used to restart system services when their config files are changed, which seems similar to what you want.

The developer docs aren't clear on how a provider for a plug-in type supports refreshing, but probably you just need it to have a particular method (named "refresh" more likely than not).  If a plug-in type is what you have in mind, then you might find the Puppet Developers group more helpful.  You could also look at the providers for types that support refreshing, especially Service.


John

Ganesh Nalawade

unread,
Oct 11, 2014, 4:39:57 AM10/11/14
to puppet...@googlegroups.com
Thanks John, your reply was very helpful.

Regards,
Ganesh

--
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/5xaXhqJSJYY/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/573ef611-a296-4883-8e20-d697ac9bf3ee%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages