chuck clark
2010-Mar-23 00:32 UTC
[Puppet Users] Is there an approach to pre and post notify for changes to a file?
I''m using puppet 0.25.2 in a RHEL5 environment and Glassfish is one of the resources under management. Managing the Glassfish configuration is proving troublesome. I have a glassfish module with a glassfish class which has the following file resource definition: "/opt/glassfish/domains/pulse/config/domain.xml": content => template("glassfish/domain-$environment.xml.erb"), owner => pulse, group => pulse, mode => 644, checksum => md5, require => Exec["ConfigureGlassfish"]; Glassfish has an annoying behavior where it writes out a cached version of the config file when it shuts down so I can''t push the file while Glassfish is running otherwise my changes get overwritten. So I need to ensure Glassfish is shut down before puppet pulls the updated file from the puppetmaster and then after the new version of the domain.xml config file is distributed Glassfish needs to be restarted. I can manage Glassfish as a service but I''m not sure how to trigger these actions pre and post update. Does anyone have any insights into how I might accomplish this? Is this a task better suited for something like ControlTier than Puppet? It isn''t specific to application building and deployment and seems to be a part of managing my infrastructure and how it is configured. thanks, chuck -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Dan Bode
2010-Mar-23 00:52 UTC
Re: [Puppet Users] Is there an approach to pre and post notify for changes to a file?
On Mon, Mar 22, 2010 at 5:32 PM, chuck clark <cclark@ziclix.com> wrote:> I''m using puppet 0.25.2 in a RHEL5 environment and Glassfish is one of the > resources under management. Managing the Glassfish configuration is proving > troublesome. > > I have a glassfish module with a glassfish class which has the following > file resource definition: > > "/opt/glassfish/domains/pulse/config/domain.xml": > content => template("glassfish/domain-$environment.xml.erb"), > owner => pulse, > group => pulse, > mode => 644, > checksum => md5, > require => Exec["ConfigureGlassfish"]; > > Glassfish has an annoying behavior where it writes out a cached version of > the config file when it shuts down so I can''t push the file while Glassfish > is running otherwise my changes get overwritten. So I need to ensure > Glassfish is shut down before puppet pulls the updated file from the > puppetmaster and then after the new version of the domain.xml config file is > distributed Glassfish needs to be restarted. I can manage Glassfish as a > service but I''m not sure how to trigger these actions pre and post update. > Does anyone have any insights into how I might accomplish this? >you could do something like the following (warning, this is a little hackish) I have heard some conversations in Dev-land about supporting these kinds of cases better in the future (dependencies on state). Its just psuedo-code below, but the basic idea should work. The code below would only change the config file if a new version needs to be deployed. It will not revert the local copy to the remote version if it changes (sounds like this is the behavior you want anyways) # stage a tmp copy of the updated file file{''/tmp/staging/domain.xml'': notify => Exec[''stop_glassfish''], source => ''blah'', } # special exec to stop exec{''stop_glassfish'' refreshonly => true, notify => Exec[''cp_domain''], } # check diffs with staging copy, copy over if its different exec{''cp_domain.xml'': command => ''cp /tmp/staging/domain.xml /blah/domain.xml'', unless => ''diff /tmp/staging/domain.xml /blah/domain.xml'', require => Exec[''stop_glassfish''], notify => Service[glassfish], refreshonly => true, } #regular glass fish service declaration service{''glassfish'' ensure => running, ... }> Is this a task better suited for something like ControlTier than Puppet? > It isn''t specific to application building and deployment and seems to be a > part of managing my infrastructure and how it is configured. >I am not sure what the best way to do this is, but it is possible to do it with Puppet.> > thanks, > chuck > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.