I''m trying to trigger a service to be refreshed when the target of a symlink changes. Here''s how it''s configured: file { "/etc/lighttpd/sites-enabled/$domain.conf": notify => service[lighttpd], ensure => "/nfs/www/$domain/etc/lighttpd.conf", links => follow, } This causes the service to be refreshed everytime puppet updates, even if the target file has not changed: debug: //www01/website[www.example.com]/file=/etc/lighttpd/sites-enabled/www.example.com.conf: Changing ensure debug: //www01/website[www.example.com]/file=/etc/lighttpd/sites-enabled/www.example.com.conf: 1 change(s) debug: //www01/website[www.example.com]/file=/etc/lighttpd/sites-enabled/www.example.com.conf/ensure: setting link (currently file) notice: //www01/website[www.example.com]/file=/etc/lighttpd/sites-enabled/www.example.com.conf/ensure: ensure changed ''file'' to ''link'' info: //www01/website[www.example.com]/file=/etc/lighttpd/sites-enabled/www.example.com.conf: Scheduling refresh of service[lighttpd] debug: //www01/server/webserver/service=lighttpd: Executing ''ps -ef'' debug: //www01/server/webserver/service=lighttpd: PID is 2075 debug: //www01/server/webserver/service=lighttpd: file[/etc/lighttpd/sites-enabled/www.example.com.conf] results in triggering refresh info: //www01/server/webserver/service=lighttpd: Triggering ''refresh'' from 1 dependencies debug: //www01/server/webserver/service=lighttpd: Executing "/etc/init.d/lighttpd reload" Puppet seems to think that the symlink is a file. If I don''t set the links parameter, the service is never refreshed. What''s the correct way to handle this? Thanks, Christian
On Sep 6, 2006, at 7:04 PM, Christian G. Warden wrote:> I''m trying to trigger a service to be refreshed when the target of > a symlink > changes. > Here''s how it''s configured: > > file { "/etc/lighttpd/sites-enabled/$domain.conf": > notify => service[lighttpd], > ensure => "/nfs/www/$domain/etc/lighttpd.conf", > links => follow, > } > > This causes the service to be refreshed everytime puppet updates, > even if the target file has not changed:I can''t decide if this is a bug or not. The problem here is that Puppet is correctly following links and determining that the destination is a file, so it thinks there''s a difference and creates the link. I think the link handling should be smarter, so that this kind of repetition can''t occur, but I can''t tell if you can even do what you want. Are you wanting to refresh if the file itself changes, or just if the target changes (e.g., $domain changes causing the link to point elsewhere)? If the latter, then remove the ''links'' attribute, or change it to ''manage'', and it works. If the former... I can''t imagine any way of making this work. I just tried some testing, and even backing up just behaves erratically. If you''ve got links => follow, then the backup system needs to know if you''re replacing the link, the destination of the link, or both, and then behave appropriately. I don''t think this is sane. I think the right option is to support *either* using ''ensure'' to set links, or using links => follow, but not both. With those two changes, I think we''d get consistent behaviour, but will that give you what you want? -- Luke Kanies http://madstop.com | http://reductivelabs.com | 615-594-8199
On Thu, Sep 14, 2006 at 01:11:58AM -0500, Luke Kanies wrote:> On Sep 6, 2006, at 7:04 PM, Christian G. Warden wrote: > > > I''m trying to trigger a service to be refreshed when the target of > > a symlink > > changes. > > Here''s how it''s configured: > > > > file { "/etc/lighttpd/sites-enabled/$domain.conf": > > notify => service[lighttpd], > > ensure => "/nfs/www/$domain/etc/lighttpd.conf", > > links => follow, > > } > > > > This causes the service to be refreshed everytime puppet updates, > > even if the target file has not changed: > > I can''t decide if this is a bug or not. > > The problem here is that Puppet is correctly following links and > determining that the destination is a file, so it thinks there''s a > difference and creates the link. > > I think the link handling should be smarter, so that this kind of > repetition can''t occur, but I can''t tell if you can even do what you > want. > > Are you wanting to refresh if the file itself changes, or just if the > target changes (e.g., $domain changes causing the link to point > elsewhere)?I''d like to refresh if the file being pointed to changes.> If the latter, then remove the ''links'' attribute, or change it to > ''manage'', and it works. If the former... I can''t imagine any way of > making this work. > > I just tried some testing, and even backing up just behaves > erratically. If you''ve got links => follow, then the backup system > needs to know if you''re replacing the link, the destination of the > link, or both, and then behave appropriately. I don''t think this is > sane. > > I think the right option is to support *either* using ''ensure'' to set > links, or using links => follow, but not both. > > With those two changes, I think we''d get consistent behaviour, but > will that give you what you want?I would think that links => follow means follow the link and notice changes. Of course, the link itself will need to be watched too because a change in the link would usually mean that the file being pointed to changed too. xn
Christian G. Warden wrote:> > I''d like to refresh if the file being pointed to changes.The problem is that the ''ensure => link'' basically conflicts with the ''links => follow''. You''re basically saying, don''t touch the link, do everything to the destination, but then that means that the destination itself should be a link. I admit that the current behaviour is probably ideal, or at least it''s not easy to predict, but what you''re trying to do is a bit difficult regardless.> I would think that links => follow means follow the link and notice > changes. Of course, the link itself will need to be watched too because > a change in the link would usually mean that the file being pointed to > changed too.It does, but ''ensure => link, links => follow'' should mean that the destination should be a link. If you just use ''links => follow, checksum => md5'', then the destination will be checksummed and you''ll get the behaviour you want. It probably makes sense to file this as a bug, or maybe an enhancement request, to remind us (me?) to take a look at what the behaviour should be. Should ''ensure'' never follow links, or what? That seems to be the behaviour you assumed, but I''m not sure it''s the right one. Does that make sense? -- Progress isn''t made by early risers. It''s made by lazy men trying to find easier ways to do something. --Robert Heinlein --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
On Fri, Sep 15, 2006 at 08:17:33PM -0500, Luke Kanies wrote:> Christian G. Warden wrote: > > > > I''d like to refresh if the file being pointed to changes. > > The problem is that the ''ensure => link'' basically conflicts with the > ''links => follow''. You''re basically saying, don''t touch the link, do > everything to the destination, but then that means that the destination > itself should be a link. > > I admit that the current behaviour is probably ideal, or at least it''s > not easy to predict, but what you''re trying to do is a bit difficult > regardless. > > > I would think that links => follow means follow the link and notice > > changes. Of course, the link itself will need to be watched too because > > a change in the link would usually mean that the file being pointed to > > changed too. > > It does, but ''ensure => link, links => follow'' should mean that the > destination should be a link. > > If you just use ''links => follow, checksum => md5'', then the destination > will be checksummed and you''ll get the behaviour you want.But I want puppet to create the link, so I need to use ensure too.> It probably makes sense to file this as a bug, or maybe an enhancement > request, to remind us (me?) to take a look at what the behaviour should > be. Should ''ensure'' never follow links, or what? That seems to be the > behaviour you assumed, but I''m not sure it''s the right one. > > Does that make sense?I guess I did assume that "ensure" will not follow the link, but instead ensure that the file itself is a symlink to the destination specified. I''m not sure it''s the best behavior either, but it makes sense to me. I would create a separate file instance if the destination of a symlink was itself supposed to be a symlink. xn
Christian G. Warden wrote:> > But I want puppet to create the link, so I need to use ensure too.> I guess I did assume that "ensure" will not follow the link, but instead > ensure that the file itself is a symlink to the destination specified. > I''m not sure it''s the best behavior either, but it makes sense to me. I > would create a separate file instance if the destination of a symlink > was itself supposed to be a symlink.I assume this behaviour will be possible, but I''m not sure there''s any behaviour that would not be confusing in this case. Please file this as a bug, and I''ll look at it. -- I can win an argument on any topic, against any opponent. People know this, and steer clear of me at parties. Often, as a sign of their great respect, they don''t even invite me. -- Dave Barry --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com