This repository has been archived by the owner on Oct 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrender.py
60 lines (42 loc) · 1.43 KB
/
render.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from yaml import load
from jinja2 import Template
################ get the variables value ##############
my_variables_file=open('variables.yml', 'r')
my_variables_in_string=my_variables_file.read()
my_variables_in_yaml=load(my_variables_in_string)
my_variables_file.close()
################# render minion conf file ###################
f=open('templates/minion.j2')
my_template = Template(f.read())
f.close()
f=open('render/minion','w')
f.write(my_template.render(my_variables_in_yaml))
f.close()
################ render proxy config file ###################
f=open('templates/proxy.j2')
my_template = Template(f.read())
f.close()
f=open('render/proxy','w')
f.write(my_template.render(my_variables_in_yaml))
f.close()
################### render junos configuration file #################
f=open('templates/syslog.j2')
my_template = Template(f.read())
f.close()
f=open('render/salt/syslog.conf','w')
f.write(my_template.render(my_variables_in_yaml))
f.close()
################### render pillar files ################################
f=open('templates/pillars_top.j2')
my_template = Template(f.read())
f.close()
f=open('render/pillar/top.sls','w')
f.write(my_template.render(my_variables_in_yaml))
f.close()
f=open('templates/pillars_device.j2')
my_template = Template(f.read())
f.close()
for item in my_variables_in_yaml['junos']:
f=open('render/pillar/' + item['name'] +'-details.sls','w')
f.write(my_template.render(item))
f.close()