Hello, Documentation mentions that Windows service resource provider "can start, stop, enable, and disable services". Is it possible to create (register) a service using this provider? I''m running stand-alone Puppet agent 3.4.2 on Windows. Thanks, Igor. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
On Wed, Aug 28, 2013 at 10:51 AM, Igor Berger <codewizard@gmail.com> wrote:> Hello, > > Documentation mentions that Windows service resource provider "can start, > stop, enable, and disable services". > > Is it possible to create (register) a service using this provider? >I don''t believe it is, but it''s possible we could add this as an enhancement (we don''t support the controllable feature in windows). For now you can use exec and a call to sc.exe to install services. http://ss64.com/nt/sc.html And a stack overflow article talking a bit about this: http://stackoverflow.com/questions/15085856/using-sc-to-install-a-windows-service-and-then-set-recovery-properties> > I''m running stand-alone Puppet agent 3.4.2 on Windows. > >I believe you meant 3.2.4. My answers were based on that version.> Thanks, > Igor. > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out. >-- Rob Reynolds Developer, Puppet Labs Join us at PuppetConf 2014, September 23-24 in San Francisco -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Thanks for a quick response. I could use SC, but there are corner cases that require a lot of exec''s and flow control, which looks quite ugly in Puppet. It would be nice if something like this was built in: 1. If service doesn''t exist, create it (sc create) 2. Set recovery actions (sc failure) 3. Re-configure the service (sc config) to change command-line arguments 4. Disable recovery (sc failureflag) in case service crashes while stopping 5. Stop service (sc stop) 6. Wait for some timeout (since "sc stop" is async) 7. If the service is still up, kill the process (powershell stop-process) 8. Copy new files 9. Re-enable recovery (sc failureflag) 10. Start service (sc start) Regards, Igor. P.S. Yes, the version is 3.2.4. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
For posterity, here''s what I ended up with (no graceful service stop): ---- $process_name = ''myprocess'' $service_name = ''myservice'' $package_source = ''C:/source'' $package_target = ''C:/target'' $service_config = "start= auto binPath= \"$package_target/bin/$process_name.exe\"" $service_exists = "powershell get-service -name $service_name" Exec { path => $::path } exec { ''create_service'': command => "sc create $service_name $service_config", unless => $service_exists, } -> exec { ''update_service'': command => "sc config $service_name $service_config", onlyif => $service_exists, } -> exec { ''configure_recovery'': command => "sc failure $service_name reset= 0 actions= restart/10000/restart/10000/restart/10000", } -> exec { ''disable_recovery'': command => "sc failureflag $service_name 0", } -> exec { ''stop_service'': command => "powershell stop-process -name $process_name", returns => [0, 1], } -> file { ''copy_package'': ensure => directory, force => true, mode => ''0600'', path => $package_target, purge => true, recurse => true, source => $package_source, } -> exec { ''inherit_permissions'': command => "icacls $package_target /reset /T", } -> exec { ''configure_service'': command => "cmd /C $package_target/config.cmd", } -> exec { ''enable_recovery'': command => "sc failureflag $service_name 1", } -> exec { ''start_service'': command => "sc start $service_name", } ---- -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.