Arnau Bria
2010-Oct-07 09:46 UTC
[Puppet Users] managing svn on client side and exec question
Hi all, I''m changing my code and I''d like to control a entire tree by svn and not puppet fileserver (we''re trying to decrease puppet load). So I''ve created a copule of execs, one for svn checkout the other for svn update. svn checkout looks like: exec { ''svn_check_out'' : cwd => ''/opt/localconf'', command => ''svn co svn://repo/ && touch /usr/local/lock/svn'', create => ''/usr/local/lock/svn'', require => Files[''localconf''], } first question, which is the best way for controlling a checkout? Is my create "lock file" mode good enough? How do other admins mange this kind of situation? then my svn update looks like: exec { ''svn_update'' : cwd => ''/opt/localconf'', command => ''svn up gLite3.1'', require => [Files[''localconf''], Exec[''svn_check_out'']], } update needs checkout, but only once. So, I''m wondering if this code is correct, or if that require svn_check_out could be coded in other way. Finally, the "exec question" is: how do you manage an exec that "depends" (unless) on 2 or more conditions? may I separate them in the unless with logical or (||)? I''d like to hear other admins experience. TIA, Arnau -- 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.
Felix Frank
2010-Oct-07 09:59 UTC
Re: [Puppet Users] managing svn on client side and exec question
On 10/07/2010 11:46 AM, Arnau Bria wrote:> Hi all, > > I''m changing my code and I''d like to control a entire tree by svn and > not puppet fileserver (we''re trying to decrease puppet load). > So I''ve created a copule of execs, one for svn checkout the other for > svn update. > > svn checkout looks like: > > exec { > ''svn_check_out'' : > cwd => ''/opt/localconf'', > command => ''svn co svn://repo/ && touch /usr/local/lock/svn'', > create => ''/usr/local/lock/svn'', > require => Files[''localconf''], > } > > > first question, which is the best way for controlling a checkout? Is my > create "lock file" mode good enough? How do other admins mange this > kind of situation?I''d rather define a sensible creates (note the final "s") parameter inside the checkout location, if that is at all possible, instead of inventing an artificial flag. This is even more important if you manage several svn checkouts like that.> then my svn update looks like: > > exec { > ''svn_update'' : > cwd => ''/opt/localconf'', > command => ''svn up gLite3.1'', > require => [Files[''localconf''], Exec[''svn_check_out'']], > } > > > update needs checkout, but only once. So, I''m wondering if this code is > correct, or if that require svn_check_out could be coded in other way.This looks correct to me. Since you use "require" and not "subscribe and refreshonly", this will lead to performing the "has checkout been made yet" check first, then running the exec invariably, which is what you want.> Finally, the "exec question" is: > > how do you manage an exec that "depends" (unless) on 2 or more conditions? > may I separate them in the unless with logical or (||)?Since the "onlyif" is executed in a shell (afaik), using shell operator like || and && is perfectly legitimate. I like to separate the commands into variables like $package = "dpkg -l ''$package*'' | awk ''\$1 ~ /ii/''" $process = "..." exec { "...": onlyif => "$package && $process" } Regards, Felix -- 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.
Arnau Bria
2010-Oct-07 10:10 UTC
Re: [Puppet Users] managing svn on client side and exec question
On Thu, 07 Oct 2010 11:59:29 +0200 Felix Frank wrote: Hi Felix,> > exec { > > ''svn_check_out'' : > > cwd => ''/opt/localconf'', > > command => ''svn co svn://repo/'', > > create => ''/opt/localconf/repo'', > > require => Files[''localconf''], > > }> I''d rather define a sensible creates (note the final "s") parameter > inside the checkout location, if that is at all possible, instead of > inventing an artificial flag. > This is even more important if you manage several svn checkouts like > that.ok, I''ll change it to repo name. Makes more sense :-) thanks. [...]> > Finally, the "exec question" is: > > > > how do you manage an exec that "depends" (unless) on 2 or more > > conditions? may I separate them in the unless with logical or (||)? > > Since the "onlyif" is executed in a shell (afaik), using shell > operator like || and && is perfectly legitimate.onlyif/unless I guess.> I like to separate the commands into variables like > $package = "dpkg -l ''$package*'' | awk ''\$1 ~ /ii/''" > $process = "..." > exec { "...": onlyif => "$package && $process" }nice.> Regards, > FelixThanks for your quick answer Felix, Cheers, Arnau -- 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.