Guest User

Untitled

a guest
Apr 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. class on_services::modify {
  2. define update_services {
  3. if ($::osfamily == 'windows') {
  4. #notify {"Updating Service: $title":}
  5. $domain_user = hiera('domain_user', undef)
  6. $domain_password = hiera('domain_password', undef)
  7.  
  8. exec { "stop_${title}":
  9. command => "C:\\Windows\\System32\\cmd.exe /c sc stop \"${title}\"",
  10. onlyif => "C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\" | find \"RUNNING\"",
  11. unless => "C:\\Windows\\System32\\cmd.exe /c sc qc \"${title}\" | find \"$domain_user\"",
  12. logoutput => true,
  13. before => Exec["update_user_${title}"],
  14. }
  15. exec { "update_user_${title}":
  16. command => "C:\\Windows\\System32\\cmd.exe /c sc config \"${title}\" type= own obj= \"${domain_user}\" password= \"${domain_password}\"",
  17. onlyif => "C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\"",
  18. unless => ["C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\" | find \"RUNNING\"",
  19. "C:\\Windows\\System32\\cmd.exe /c sc qc \"${title}\" | find \"$domain_user\""],
  20. logoutput => true,
  21. require => Exec["stop_${title}"],
  22. before => Exec["start_${title}"],
  23. }
  24. exec { "start_${title}":
  25. command => "C:\\Windows\\System32\\cmd.exe /c sc start \"${title}\"",
  26. onlyif => "C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\"",
  27. unless => "C:\\Windows\\System32\\cmd.exe /c sc query \"${title}\" | find \"RUNNING\"",
  28. logoutput => true,
  29. require => Exec["update_user_${title}"],
  30. }
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment