Jesús M. Navarro
2010-Apr-28 20:10 UTC
[Puppet Users] Refresh an exec only if another file changes
Hi, list: I''m trying to add a Debian-based Xen Dom0 server to puppet management. One of the files I want to consider is /boot/grub/menu.lst since it contains some Xen-related options. When managing it by hand I''d produce a skeleton for menu.lst and then I''d execute update-grub, which would look for avaliable kernels and would add related configs to the menu.lst contents. My first idea came in the lines of (within a class): file { "/boot/grub/menu.lst": mode => "0644", owner => root, group => root, notify => Exec["update-grub"], source => "puppet:///s_virtualcluster/menu.lst"; } exec { "update-grub": path => "/usr/bin:/usr/sbin:/bin", refreshonly => true, } But since update-grub changes /boot/grub/menu.lst itself, the menu.lst template gets downloaded and update-grub triggered each time puppet runs. Is there an ellegant manner to deal with it? (like downloading menu.lst to a different path, and then run update-grub only if md5sum of the real menu.lst has changed from previous puppet run or if the server version from menu.lst has changed? TIA. -- 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.
Patrick
2010-Apr-28 21:42 UTC
Re: [Puppet Users] Refresh an exec only if another file changes
On Apr 28, 2010, at 1:10 PM, Jesús M. Navarro wrote:> Hi, list: > > I''m trying to add a Debian-based Xen Dom0 server to puppet management. > > One of the files I want to consider is /boot/grub/menu.lst since it contains > some Xen-related options. > > When managing it by hand I''d produce a skeleton for menu.lst and then I''d > execute update-grub, which would look for avaliable kernels and would add > related configs to the menu.lst contents. > > My first idea came in the lines of (within a class): > file { > "/boot/grub/menu.lst": > mode => "0644", > owner => root, > group => root, > notify => Exec["update-grub"], > source => "puppet:///s_virtualcluster/menu.lst"; > } > exec { "update-grub": > path => "/usr/bin:/usr/sbin:/bin", > refreshonly => true, > } > > But since update-grub changes /boot/grub/menu.lst itself, the menu.lst > template gets downloaded and update-grub triggered each time puppet runs. > > Is there an ellegant manner to deal with it? (like downloading menu.lst to a > different path, and then run update-grub only if md5sum of the real menu.lst > has changed from previous puppet run or if the server version from menu.lst > has changed?I won''t call this way elegant, but there is an easy way to do it. file { "/boot/grub/server_menu.lst": mode => "0644", owner => root, group => root, notify => Exec["updated_menu.lst"], source => "puppet:///s_virtualcluster/menu.lst"; } exec { "cp -p /boot/grub/server_menu.lst /boot/grub/menu.lst": path => "/usr/bin:/usr/sbin:/bin", alias => "updated_menu.lst", refreshonly => true, notify => Exec["update-grub"], } exec { "update-grub": path => "/usr/bin:/usr/sbin:/bin", refreshonly => true, } -- 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.
Jesús M. Navarro
2010-Apr-29 00:02 UTC
Re: [Puppet Users] Refresh an exec only if another file changes
Hi, Patrick: On Wednesday 28 April 2010 23:42:38 Patrick wrote:> On Apr 28, 2010, at 1:10 PM, Jesús M. Navarro wrote: > > Hi, list: > > > > I''m trying to add a Debian-based Xen Dom0 server to puppet management.[...]> I won''t call this way elegant, but there is an easy way to do it. > > > file { > "/boot/grub/server_menu.lst": > mode => "0644", > owner => root, > group => root, > notify => Exec["updated_menu.lst"], > source => "puppet:///s_virtualcluster/menu.lst"; > } > > exec { "cp -p /boot/grub/server_menu.lst /boot/grub/menu.lst": > path => "/usr/bin:/usr/sbin:/bin", > alias => "updated_menu.lst", > refreshonly => true, > notify => Exec["update-grub"], > } > > exec { "update-grub": > path => "/usr/bin:/usr/sbin:/bin", > refreshonly => true, > }First of all, thanks for your help. I think your idea covers the first part of the equation but unless I misunderstood, it won''t cope with the second part. From what I see, yours will cope with the case where I update menu.lst server-side, but what if somebody changes the client''s copy of /boot/grub/menu.lst? It seems puppet won''t notice it so won''t recover the "proper" contents (as per the puppetmaster idea of it). Am I right? Cheers and thank you for your interest. -- 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.
Patrick
2010-Apr-29 01:22 UTC
Re: [Puppet Users] Refresh an exec only if another file changes
On Apr 28, 2010, at 5:02 PM, Jesús M. Navarro wrote:> Hi, Patrick: > > On Wednesday 28 April 2010 23:42:38 Patrick wrote: >> On Apr 28, 2010, at 1:10 PM, Jesús M. Navarro wrote: >>> Hi, list: >>> >>> I''m trying to add a Debian-based Xen Dom0 server to puppet management. > > [...] > >> I won''t call this way elegant, but there is an easy way to do it. >> >> >> file { >> "/boot/grub/server_menu.lst": >> mode => "0644", >> owner => root, >> group => root, >> notify => Exec["updated_menu.lst"], >> source => "puppet:///s_virtualcluster/menu.lst"; >> } >> >> exec { "cp -p /boot/grub/server_menu.lst /boot/grub/menu.lst": >> path => "/usr/bin:/usr/sbin:/bin", >> alias => "updated_menu.lst", >> refreshonly => true, >> notify => Exec["update-grub"], >> } >> >> exec { "update-grub": >> path => "/usr/bin:/usr/sbin:/bin", >> refreshonly => true, >> } > > First of all, thanks for your help. I think your idea covers the first part > of the equation but unless I misunderstood, it won''t cope with the second > part. > > From what I see, yours will cope with the case where I update menu.lst > server-side, but what if somebody changes the client''s copy > of /boot/grub/menu.lst? It seems puppet won''t notice it so won''t recover > the "proper" contents (as per the puppetmaster idea of it). Am I right? > > Cheers and thank you for your interest.You''re right. It won''t do that. Try removing refreshonly on the second command, and replacing it with an "unless" or "onlyif" that uses /usr/bin/diff. -Patrick -- 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.
Peter Meier
2010-Apr-29 06:32 UTC
Re: [Puppet Users] Refresh an exec only if another file changes
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> From what I see, yours will cope with the case where I update menu.lst > server-side, but what if somebody changes the client''s copy > of /boot/grub/menu.lst? It seems puppet won''t notice it so won''t recover > the "proper" contents (as per the puppetmaster idea of it). Am I right?How do you detect whether update-grub or a human have edited the file? As Patrick outlined this detection has then to go into onlyif or unless. cheers pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkvZKBMACgkQbwltcAfKi3/+nQCeN0Qwn0ls3sKtrf+AsvzZI2CW BVcAnjjNH96m0X8LXHD/NhLUiTDXXgYD =iREk -----END PGP SIGNATURE----- -- 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.
David Schmitt
2010-Apr-29 09:49 UTC
Re: [Puppet Users] Refresh an exec only if another file changes
On 4/28/2010 10:10 PM, Jesús M. Navarro wrote:> Hi, list: > > I''m trying to add a Debian-based Xen Dom0 server to puppet management. > > One of the files I want to consider is /boot/grub/menu.lst since it contains > some Xen-related options. > > When managing it by hand I''d produce a skeleton for menu.lst and then I''d > execute update-grub, which would look for avaliable kernels and would add > related configs to the menu.lst contents. > > My first idea came in the lines of (within a class): > file { > "/boot/grub/menu.lst": > mode => "0644", > owner => root, > group => root, > notify => Exec["update-grub"], > source => "puppet:///s_virtualcluster/menu.lst"; > } > exec { "update-grub": > path => "/usr/bin:/usr/sbin:/bin", > refreshonly => true, > } > > But since update-grub changes /boot/grub/menu.lst itself, the menu.lst > template gets downloaded and update-grub triggered each time puppet runs. > > Is there an ellegant manner to deal with it? (like downloading menu.lst to a > different path, and then run update-grub only if md5sum of the real menu.lst > has changed from previous puppet run or if the server version from menu.lst > has changed?Puppet already provides for exactly this check. Add checksum => md5 to the file and it will only notify when the actual contents change. Best Regards, David -- dasz.at OG Tel: +43 (0)664 2602670 Web: http://dasz.at Klosterneuburg UID: ATU64260999 FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg -- 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.