salt.renderers.py

Pure python state renderer

The sls file should contain a function called run which returns high state data

In this module, a few objects are defined for you, including the usual (with``__`` added) __salt__ dictionary, __grains__, __pillar__, __opts__, __env__, and __sls__.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 #!py

 def run():
     config = {}

     if __grains__['os'] == 'Ubuntu':
         user = 'ubuntu'
         group = 'ubuntu'
         home = '/home/{0}'.format(user)
     else:
         user = 'root'
         group = 'root'
         home = '/root/'

     config['s3cmd'] = {
         'pkg': [
             'installed',
             {'name': 's3cmd'},
         ],
     }

     config[home + '/.s3cfg'] = {
         'file.managed': [
             {'source': 'salt://s3cfg/templates/s3cfg'},
             {'template': 'jinja'},
             {'user': user},
             {'group': group},
             {'mode': 600},
             {'context': {
                 'aws_key': __pillar__['AWS_ACCESS_KEY_ID'],
                 'aws_secret_key': __pillar__['AWS_SECRET_ACCESS_KEY'],
                 },
             },
         ],
     }

     return config
salt.renderers.py.render(template, saltenv='base', sls='', tmplpath=None, **kws)

Render the python module's components

Return type:string

Current Salt release: 2014.1.6

Docs for previous releases on salt.rtfd.org.

Previous topic

salt.renderers.mako

Next topic

salt.renderers.pydsl

Upcoming SaltStack Events