Advertisement
fmartinelli

pyobjects saltstack example

Apr 17th, 2014
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. #!pyobjects
  2.  
  3.  
  4. ######### to be written somewhere else as a general function #####
  5. def t3source( FILEPATH ):
  6.   import os
  7.   import re
  8.   HOSTNAME     = os.uname()[1]
  9.   FILE_POSTFIX = re.split( '[0-9][0-9]', HOSTNAME )[0]
  10.   SOURCE       = 'salt://'
  11.   FILE         = '/etc/sudoers'
  12.   OS           = __salt__['grains.get']('os')           # ScientificLinux
  13.   OSREL        = __salt__['grains.get']('osrelease')[0] # 5
  14.   SOURCE       = 'salt://' + 'OS/'+OS+'/'+OSREL+'/files'+FILEPATH
  15.   return [  SOURCE + '__' + FILE_POSTFIX        ,
  16.             SOURCE                               ]
  17. ##################################################################
  18.  
  19. with Pkg.installed( 'sudo' ):
  20.   File.directory("/etc/sudoers.d" , user = 'root', group = 'root', mode = '0550' )
  21.  
  22.   FILEPATH = "/etc/sudoers"
  23.  
  24.   File.managed( FILEPATH  ,
  25.                user = 'root'  ,
  26.                group = 'root' ,
  27.                mode = '0440'  ,
  28.                source= t3source( FILEPATH ) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement