Jason Edgecombe
2012-Dec-30 02:27 UTC
[Puppet Users] exec type doesn''t refresh when onlyif is in use
Hi, I''m having trouble with an exec type. I''m using an exec type to start a buildbot slave. It''s a long-running pseudo-service. The exec uses the "refresh" and "onlyif". I think that the refresh command isn''t running because of the onlyif attribute. I would like a refresh event to fire even if the "onlyif" attribute is in use. Any help is appreciated. Do I need to split it into two exec''s (one normal and another refreshonly)? Here is a snippet from the type definition: =============define buildbot::slave::instance( ..., $project_dir, ... ) { $path = [''/usr/local/bin'',''/usr/bin'',''/bin''] $config_files = ["$project_dir/info/admin","$project_dir/info/host"] # commands to work with the buildslave $slave_install_command = "buildslave create-slave $project_dir $master_host_port $slave_name $slave_password" $slave_start_command = "buildslave start $project_dir" $slave_restart_command = "buildslave restart $project_dir" $slave_status_command = "/bin/kill -0 `/bin/cat $project_dir/twistd.pid`" ...snip... exec { $slave_start_command: cwd => $project_dir, path => $path, user => $user, group => $group, unless => $slave_status_command, refresh => $slave_restart_command, require => File[$config_files], subscribe => File[$config_files], } =====Here is part of the debug log: Info: /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]: Filebucketed /home/buildslave/buildbot/openafs/info/ad min to puppet with sum 2f840fdf8acf7c334c293c9da0879721 /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]/content: content changed ''{md5}2f840fdf8acf7c334c293c9da0879721'' to ''{md5}18eca080dfec8ff8fc47a54bf6a96226'' Info: /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]: Scheduling refresh of Exec[buildslave start /home/buildslave/buildbot/openafs] Debug: /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]: The container Buildbot::Slave::Instance[openafs1] will propagate my refresh event Debug: Exec[buildslave start /home/buildslave/buildbot/openafs](provider=posix): Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' Debug: Exec[buildslave start /home/buildslave/buildbot/openafs](provider=posix): Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' /Stage[main]//Buildbot::Slave::Instance[openafs1]/Exec[buildslave start /home/buildslave/buildbot/openafs]: Triggered ''refresh'' from 1 events Debug: /Stage[main]//Buildbot::Slave::Instance[openafs1]/Exec[buildslave start /home/buildslave/buildbot/openafs]: The container Buildbot::Slave::Instance[openafs1] will propagate my refresh event Debug: Buildbot::Slave::Instance[openafs1]: The container Class[Main] will propagate my refresh event Debug: Class[Main]: The container Stage[main] will propagate my refresh event Thanks, Jason -- 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.
Maarten Thibaut (mthibaut)
2012-Dec-30 02:38 UTC
Re: [Puppet Users] exec type doesn''t refresh when onlyif is in use
Hi, I believe the onlyif "wins" in this case. Splitting it up into two statements would be the right thing to do IMO. It would also be cleaner, since they are in effect two different cases: stopped (and in need of starting), and running (but in need of restart). The fact that these both run the same command is incidental. Don''t think low-level, think high-level! Sent from my iPhone On 30 Dec 2012, at 03:27, "Jason Edgecombe" <jason@rampaginggeek.com> wrote:> Hi, > > I''m having trouble with an exec type. I''m using an exec type to start a buildbot slave. It''s a long-running pseudo-service. The exec uses the "refresh" and "onlyif". I think that the refresh command isn''t running because of the onlyif attribute. I would like a refresh event to fire even if the "onlyif" attribute is in use. Any help is appreciated. Do I need to split it into two exec''s (one normal and another refreshonly)? > > > Here is a snippet from the type definition: > =============> define buildbot::slave::instance( ..., $project_dir, ... ) { > > $path = [''/usr/local/bin'',''/usr/bin'',''/bin''] > $config_files = ["$project_dir/info/admin","$project_dir/info/host"] > > # commands to work with the buildslave > $slave_install_command = "buildslave create-slave $project_dir $master_host_port $slave_name $slave_password" > $slave_start_command = "buildslave start $project_dir" > $slave_restart_command = "buildslave restart $project_dir" > $slave_status_command = "/bin/kill -0 `/bin/cat $project_dir/twistd.pid`" > > ...snip... > > exec { $slave_start_command: > cwd => $project_dir, > path => $path, > user => $user, > group => $group, > unless => $slave_status_command, > refresh => $slave_restart_command, > require => File[$config_files], > subscribe => File[$config_files], > } > =====> Here is part of the debug log: > > Info: /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]: Filebucketed /home/buildslave/buildbot/openafs/info/ad > min to puppet with sum 2f840fdf8acf7c334c293c9da0879721 > /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]/content: content changed ''{md5}2f840fdf8acf7c334c293c9da0879721'' to ''{md5}18eca080dfec8ff8fc47a54bf6a96226'' > Info: /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]: Scheduling refresh of Exec[buildslave start /home/buildslave/buildbot/openafs] > Debug: /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]: The container Buildbot::Slave::Instance[openafs1] will propagate my refresh event > Debug: Exec[buildslave start /home/buildslave/buildbot/openafs](provider=posix): Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' > Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' > Debug: Exec[buildslave start /home/buildslave/buildbot/openafs](provider=posix): Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' > Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' > /Stage[main]//Buildbot::Slave::Instance[openafs1]/Exec[buildslave start /home/buildslave/buildbot/openafs]: Triggered ''refresh'' from 1 events > Debug: /Stage[main]//Buildbot::Slave::Instance[openafs1]/Exec[buildslave start /home/buildslave/buildbot/openafs]: The container Buildbot::Slave::Instance[openafs1] will propagate my refresh event > Debug: Buildbot::Slave::Instance[openafs1]: The container Class[Main] will propagate my refresh event > Debug: Class[Main]: The container Stage[main] will propagate my refresh event > > > Thanks, > Jason > > -- > 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. >-- 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.
Jason Edgecombe
2012-Dec-30 03:12 UTC
Re: [Puppet Users] exec type doesn''t refresh when onlyif is in use
Thanks, that worked! On 12/29/2012 09:38 PM, Maarten Thibaut (mthibaut) wrote:> Hi, > > I believe the onlyif "wins" in this case. Splitting it up into two statements would be the right thing to do IMO. > > It would also be cleaner, since they are in effect two different cases: stopped (and in need of starting), and running (but in need of restart). > > The fact that these both run the same command is incidental. Don''t think low-level, think high-level! > > Sent from my iPhone > > On 30 Dec 2012, at 03:27, "Jason Edgecombe" <jason@rampaginggeek.com> wrote: > >> Hi, >> >> I''m having trouble with an exec type. I''m using an exec type to start a buildbot slave. It''s a long-running pseudo-service. The exec uses the "refresh" and "onlyif". I think that the refresh command isn''t running because of the onlyif attribute. I would like a refresh event to fire even if the "onlyif" attribute is in use. Any help is appreciated. Do I need to split it into two exec''s (one normal and another refreshonly)? >> >> >> Here is a snippet from the type definition: >> =============>> define buildbot::slave::instance( ..., $project_dir, ... ) { >> >> $path = [''/usr/local/bin'',''/usr/bin'',''/bin''] >> $config_files = ["$project_dir/info/admin","$project_dir/info/host"] >> >> # commands to work with the buildslave >> $slave_install_command = "buildslave create-slave $project_dir $master_host_port $slave_name $slave_password" >> $slave_start_command = "buildslave start $project_dir" >> $slave_restart_command = "buildslave restart $project_dir" >> $slave_status_command = "/bin/kill -0 `/bin/cat $project_dir/twistd.pid`" >> >> ...snip... >> >> exec { $slave_start_command: >> cwd => $project_dir, >> path => $path, >> user => $user, >> group => $group, >> unless => $slave_status_command, >> refresh => $slave_restart_command, >> require => File[$config_files], >> subscribe => File[$config_files], >> } >> =====>> Here is part of the debug log: >> >> Info: /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]: Filebucketed /home/buildslave/buildbot/openafs/info/ad >> min to puppet with sum 2f840fdf8acf7c334c293c9da0879721 >> /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]/content: content changed ''{md5}2f840fdf8acf7c334c293c9da0879721'' to ''{md5}18eca080dfec8ff8fc47a54bf6a96226'' >> Info: /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]: Scheduling refresh of Exec[buildslave start /home/buildslave/buildbot/openafs] >> Debug: /Stage[main]//Buildbot::Slave::Instance[openafs1]/File[/home/buildslave/buildbot/openafs/info/admin]: The container Buildbot::Slave::Instance[openafs1] will propagate my refresh event >> Debug: Exec[buildslave start /home/buildslave/buildbot/openafs](provider=posix): Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' >> Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' >> Debug: Exec[buildslave start /home/buildslave/buildbot/openafs](provider=posix): Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' >> Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/openafs/twistd.pid`'' >> /Stage[main]//Buildbot::Slave::Instance[openafs1]/Exec[buildslave start /home/buildslave/buildbot/openafs]: Triggered ''refresh'' from 1 events >> Debug: /Stage[main]//Buildbot::Slave::Instance[openafs1]/Exec[buildslave start /home/buildslave/buildbot/openafs]: The container Buildbot::Slave::Instance[openafs1] will propagate my refresh event >> Debug: Buildbot::Slave::Instance[openafs1]: The container Class[Main] will propagate my refresh event >> Debug: Class[Main]: The container Stage[main] will propagate my refresh event >> >> >> Thanks, >> Jason >> >> -- >> 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. >>-- 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.
Erik Dalén
2012-Dec-30 12:53 UTC
Re: [Puppet Users] exec type doesn''t refresh when onlyif is in use
Wouldn''t it be easier to use a service definition with the base provider and supply your start, restart & status commands? On 30 December 2012 03:27, Jason Edgecombe <jason@rampaginggeek.com> wrote:> Hi, > > I''m having trouble with an exec type. I''m using an exec type to start a > buildbot slave. It''s a long-running pseudo-service. The exec uses the > "refresh" and "onlyif". I think that the refresh command isn''t running > because of the onlyif attribute. I would like a refresh event to fire even > if the "onlyif" attribute is in use. Any help is appreciated. Do I need to > split it into two exec''s (one normal and another refreshonly)? > > > Here is a snippet from the type definition: > =============> define buildbot::slave::instance( ..., $project_dir, ... ) { > > $path = [''/usr/local/bin'',''/usr/bin'',''**/bin''] > $config_files = ["$project_dir/info/admin","$** > project_dir/info/host"] > > # commands to work with the buildslave > $slave_install_command = "buildslave create-slave $project_dir > $master_host_port $slave_name $slave_password" > $slave_start_command = "buildslave start $project_dir" > $slave_restart_command = "buildslave restart $project_dir" > $slave_status_command = "/bin/kill -0 `/bin/cat > $project_dir/twistd.pid`" > > ...snip... > > exec { $slave_start_command: > cwd => $project_dir, > path => $path, > user => $user, > group => $group, > unless => $slave_status_command, > refresh => $slave_restart_command, > require => File[$config_files], > subscribe => File[$config_files], > } > =====> Here is part of the debug log: > > Info: /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/File[/** > home/buildslave/buildbot/**openafs/info/admin]: Filebucketed > /home/buildslave/buildbot/**openafs/info/ad > min to puppet with sum 2f840fdf8acf7c334c293c9da08797**21 > /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/File[/** > home/buildslave/buildbot/**openafs/info/admin]/content: content changed > ''{md5}**2f840fdf8acf7c334c293c9da08797**21'' to ''{md5}** > 18eca080dfec8ff8fc47a54bf6a962**26'' > Info: /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/File[/** > home/buildslave/buildbot/**openafs/info/admin]: Scheduling refresh of > Exec[buildslave start /home/buildslave/buildbot/**openafs] > Debug: /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/File[/** > home/buildslave/buildbot/**openafs/info/admin]: The container > Buildbot::Slave::Instance[**openafs1] will propagate my refresh event > Debug: Exec[buildslave start /home/buildslave/buildbot/**openafs](provider=posix): > Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/** > openafs/twistd.pid`'' > Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/** > openafs/twistd.pid`'' > Debug: Exec[buildslave start /home/buildslave/buildbot/**openafs](provider=posix): > Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/** > openafs/twistd.pid`'' > Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/** > openafs/twistd.pid`'' > /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/Exec[**buildslave > start /home/buildslave/buildbot/**openafs]: Triggered ''refresh'' from 1 > events > Debug: /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/Exec[**buildslave > start /home/buildslave/buildbot/**openafs]: The container > Buildbot::Slave::Instance[**openafs1] will propagate my refresh event > Debug: Buildbot::Slave::Instance[**openafs1]: The container Class[Main] > will propagate my refresh event > Debug: Class[Main]: The container Stage[main] will propagate my refresh > event > > > Thanks, > Jason > > -- > 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<http://groups.google.com/group/puppet-users?hl=en> > . > >-- Erik Dalén -- 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.
Jason Edgecombe
2012-Dec-30 14:47 UTC
Re: [Puppet Users] exec type doesn''t refresh when onlyif is in use
On 12/30/2012 07:53 AM, Erik Dalén wrote:> Wouldn''t it be easier to use a service definition with the base provider > and supply your start, restart & status commands? > > > On 30 December 2012 03:27, Jason Edgecombe <jason@rampaginggeek.com> wrote: > >> Hi, >> >> I''m having trouble with an exec type. I''m using an exec type to start a >> buildbot slave. It''s a long-running pseudo-service. The exec uses the >> "refresh" and "onlyif". I think that the refresh command isn''t running >> because of the onlyif attribute. I would like a refresh event to fire even >> if the "onlyif" attribute is in use. Any help is appreciated. Do I need to >> split it into two exec''s (one normal and another refreshonly)? >> >> >> Here is a snippet from the type definition: >> =============>> define buildbot::slave::instance( ..., $project_dir, ... ) { >> >> $path = [''/usr/local/bin'',''/usr/bin'',''**/bin''] >> $config_files = ["$project_dir/info/admin","$** >> project_dir/info/host"] >> >> # commands to work with the buildslave >> $slave_install_command = "buildslave create-slave $project_dir >> $master_host_port $slave_name $slave_password" >> $slave_start_command = "buildslave start $project_dir" >> $slave_restart_command = "buildslave restart $project_dir" >> $slave_status_command = "/bin/kill -0 `/bin/cat >> $project_dir/twistd.pid`" >> >> ...snip... >> >> exec { $slave_start_command: >> cwd => $project_dir, >> path => $path, >> user => $user, >> group => $group, >> unless => $slave_status_command, >> refresh => $slave_restart_command, >> require => File[$config_files], >> subscribe => File[$config_files], >> } >> =====>> Here is part of the debug log: >> >> Info: /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/File[/** >> home/buildslave/buildbot/**openafs/info/admin]: Filebucketed >> /home/buildslave/buildbot/**openafs/info/ad >> min to puppet with sum 2f840fdf8acf7c334c293c9da08797**21 >> /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/File[/** >> home/buildslave/buildbot/**openafs/info/admin]/content: content changed >> ''{md5}**2f840fdf8acf7c334c293c9da08797**21'' to ''{md5}** >> 18eca080dfec8ff8fc47a54bf6a962**26'' >> Info: /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/File[/** >> home/buildslave/buildbot/**openafs/info/admin]: Scheduling refresh of >> Exec[buildslave start /home/buildslave/buildbot/**openafs] >> Debug: /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/File[/** >> home/buildslave/buildbot/**openafs/info/admin]: The container >> Buildbot::Slave::Instance[**openafs1] will propagate my refresh event >> Debug: Exec[buildslave start /home/buildslave/buildbot/**openafs](provider=posix): >> Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/** >> openafs/twistd.pid`'' >> Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/** >> openafs/twistd.pid`'' >> Debug: Exec[buildslave start /home/buildslave/buildbot/**openafs](provider=posix): >> Executing check ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/** >> openafs/twistd.pid`'' >> Debug: Executing ''/bin/kill -0 `/bin/cat /home/buildslave/buildbot/** >> openafs/twistd.pid`'' >> /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/Exec[**buildslave >> start /home/buildslave/buildbot/**openafs]: Triggered ''refresh'' from 1 >> events >> Debug: /Stage[main]//Buildbot::Slave:**:Instance[openafs1]/Exec[**buildslave >> start /home/buildslave/buildbot/**openafs]: The container >> Buildbot::Slave::Instance[**openafs1] will propagate my refresh event >> Debug: Buildbot::Slave::Instance[**openafs1]: The container Class[Main] >> will propagate my refresh event >> Debug: Class[Main]: The container Stage[main] will propagate my refresh >> event >> >> >> Thanks, >> Jason >> >> -- >> 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<http://groups.google.com/group/puppet-users?hl=en> >> . >> >> >I''ve thought about that. This is a basically a service, but I can have multiple instances of the process running with different configurations. As I understand, I would need to create a new service script for each instance. Jason -- 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.
Ramin K
2012-Dec-30 21:30 UTC
Re: [Puppet Users] exec type doesn''t refresh when onlyif is in use
On 12/30/2012 6:47 AM, Jason Edgecombe wrote:> I''ve thought about that. This is a basically a service, but I can have > multiple instances of the process running with different > configurations. As I understand, I would need to create a new service > script for each instance. > > JasonWe manage many instances of Redis which is somewhat the same problem. I found it simpler to template init scripts and config files in order to use the native types within Puppet. The allows sudo service redis-server-stage restart work without having to refer to documentation or read what inputs the script needs. Also services start normally when the box comes up without having to wait for a Puppet run and makes it simpler to see what should be running on a box or is running. Ramin modules/redis/manifests/server.pp # We use ${port} for the resource declarations and ${name} for # path so that it should be impossible to create conflicting # servers using the same port and/or the same name define redis::server ( $port, $master=''localhost'', $master_port=$port ) { include redis::params File { owner => root, group => redis, mode => ''0640'', } file { "redis_${port}.conf": ensure => present, path => "${redis::params::configdir}/redis_multi_${name}.conf", content => template(''redis/redis_multi.conf.erb''), notify => Service["redis-server-${port}"], } file { "redis_slave_${port}.conf": ensure => present, path => "${redis::params::configdir}/slave_multi_${name}.conf", content => template(''redis/slave_multi.conf.erb''), notify => Service["redis-server-${port}"], } file { "redis-server-${port}": ensure => present, path => "/etc/init.d/redis-server-${name}", content => template(''redis/init_multi.erb''), notify => Service["redis-server-${port}"], mode => ''0755'', } service { "redis-server-${port}": ensure => running, enable => true, hasrestart => true, hasstatus => $redis::params::hasstatus, name => "redis-server-${name}", } nrpe::redis { $name: port => $port, } Class[''redis::service''] -> Redis::Server[$name] } -- 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.
Jason Edgecombe
2012-Dec-30 21:58 UTC
Re: [Puppet Users] exec type doesn''t refresh when onlyif is in use
On 12/30/2012 04:30 PM, Ramin K wrote:> On 12/30/2012 6:47 AM, Jason Edgecombe wrote: >> I''ve thought about that. This is a basically a service, but I can have >> multiple instances of the process running with different >> configurations. As I understand, I would need to create a new service >> script for each instance. >> >> Jason > > We manage many instances of Redis which is somewhat the same > problem. I found it simpler to template init scripts and config files > in order to use the native types within Puppet. The allows sudo > service redis-server-stage restart work without having to refer to > documentation or read what inputs the script needs. Also services > start normally when the box comes up without having to wait for a > Puppet run and makes it simpler to see what should be running on a box > or is running. > > Ramin > > modules/redis/manifests/server.pp > > # We use ${port} for the resource declarations and ${name} for > # path so that it should be impossible to create conflicting > # servers using the same port and/or the same name > define redis::server ( > $port, > $master=''localhost'', > $master_port=$port > ) { > > include redis::params > > File { > owner => root, > group => redis, > mode => ''0640'', > } > > file { "redis_${port}.conf": > ensure => present, > path => "${redis::params::configdir}/redis_multi_${name}.conf", > content => template(''redis/redis_multi.conf.erb''), > notify => Service["redis-server-${port}"], > } > > file { "redis_slave_${port}.conf": > ensure => present, > path => "${redis::params::configdir}/slave_multi_${name}.conf", > content => template(''redis/slave_multi.conf.erb''), > notify => Service["redis-server-${port}"], > } > > file { "redis-server-${port}": > ensure => present, > path => "/etc/init.d/redis-server-${name}", > content => template(''redis/init_multi.erb''), > notify => Service["redis-server-${port}"], > mode => ''0755'', > } > > service { "redis-server-${port}": > ensure => running, > enable => true, > hasrestart => true, > hasstatus => $redis::params::hasstatus, > name => "redis-server-${name}", > } > > nrpe::redis { $name: port => $port, } > > Class[''redis::service''] -> Redis::Server[$name] > } >Hi Ramin, That''s cool, thanks for sharing! I have the double-exec method working for now, and that works for a development VM, but I''ll consider this for a future improvement. Thanks, Jason -- 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.