Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class on_services::modify {
- define update_services {
- if ($::osfamily == 'windows') {
- #notify {"Updating Service: $title":}
- $domain_user = hiera('domain_user', undef)
- $domain_password = hiera('domain_password', undef)
- exec { "stop_${title}":
- command => "C:\\Windows\\System32\\cmd.exe /c sc stop \"${title}\"",
- onlyif => "C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\" | find \"RUNNING\"",
- unless => "C:\\Windows\\System32\\cmd.exe /c sc qc \"${title}\" | find \"$domain_user\"",
- logoutput => true,
- before => Exec["update_user_${title}"],
- }
- exec { "update_user_${title}":
- command => "C:\\Windows\\System32\\cmd.exe /c sc config \"${title}\" type= own obj= \"${domain_user}\" password= \"${domain_password}\"",
- onlyif => "C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\"",
- unless => ["C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\" | find \"RUNNING\"",
- "C:\\Windows\\System32\\cmd.exe /c sc qc \"${title}\" | find \"$domain_user\""],
- logoutput => true,
- require => Exec["stop_${title}"],
- before => Exec["start_${title}"],
- }
- exec { "start_${title}":
- command => "C:\\Windows\\System32\\cmd.exe /c sc start \"${title}\"",
- onlyif => "C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\"",
- unless => "C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\" | find \"RUNNING\"",
- logoutput => true,
- require => Exec["update_user_${title}"],
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment