Advertisement
Guest User

Untitled

a guest
May 24th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. __virtualname__ = 'puppet_mgmt'
  2. __author__ = "Dan Finn"
  3. __version__ = "0.1"
  4.  
  5. import subprocess
  6.  
  7. '''
  8. This module is used to restart puppet. We were seeing an issue on ubuntu servers where if you just ran cmd.run service restart puppet you would end up with puppet running under the same environment variables as the salt minion. This causes some issues for puppet so we need to specify the environment variable when we start it up.
  9.  
  10.  
  11. You can run this module like so:
  12.  
  13. salt 'hostname' puppet_mgmt.restart
  14. salt 'hostname' puppet_mgmt.stop
  15. salt 'hostname' puppet_mgmt.start
  16. '''
  17.  
  18. __virtualname = 'puppet_mgmt'
  19.  
  20. def __virtual__():
  21. return __virtualname__
  22.  
  23. def restart():
  24. '''
  25. restarts puppet
  26. '''
  27. #return_code = subprocess.call(['env', 'LC_ALL=en_US.UTF-8', 'service', 'puppet', 'restart'])
  28. # cmd = '{0} {1} {2} {3} {4}'.format('env', 'LC_ALL=en_US.UTF-8', 'service', 'puppet', 'restart')
  29. # ret = salt['cmd.run'](cmd)
  30. #__salt__['cmd.run'](run='service puppet restart',env=[{"LC_ALL":"en_US.UTF-8"}])
  31. #__salt__['cmd.run']('service puppet restart',env='{LC_ALL: en_US.UTF-8"}')
  32. #__salt__['cmd.run']('/bin/bash service puppet restart')
  33. __salt__['cmd.run']('service puppet restart',reset_system_locale=False)
  34. return "Restarting puppet"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement