New version of salt-formula from Saltstack
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

302 lines
9.5KB

  1. {%- from "salt/map.jinja" import master with context %}
  2. {%- from "linux/map.jinja" import system with context %}
  3. worker_threads: {{ master.worker_threads }}
  4. timeout: {{ master.command_timeout }}
  5. {%- if master.interface is defined %}
  6. interface: {{ master.interface }}
  7. {%- endif %}
  8. {%- if master.max_open_files is defined %}
  9. max_open_files: {{ master.max_open_files }}
  10. {%- endif %}
  11. {%- if master.pki_dir is defined %}
  12. pki_dir: {{ master.pki_dir }}
  13. {%- endif %}
  14. {%- if master.cachedir is defined %}
  15. cachedir: {{ master.cachedir }}
  16. {%- endif %}
  17. state_output: {{ master.get('state_output', 'changes') }}
  18. {%- if master.gitfs_base is defined %}
  19. gitfs_base: {{ master.gitfs_base }}
  20. {%- endif %}
  21. {%- if master.gitfs_root is defined %}
  22. gitfs_root: {{ master.gitfs_root }}
  23. {%- endif %}
  24. {%- if master.gitfs_ssl_verify is defined %}
  25. gitfs_ssl_verify: {{ master.gitfs_ssl_verify }}
  26. {%- endif %}
  27. {%- if master.gitfs_mountpoint is defined %}
  28. gitfs_mountpoint: {{ master.gitfs_mountpoint }}
  29. {%- endif %}
  30. {%- if master.gitfs_user is defined %}
  31. gitfs_user: {{ master.gitfs_user }}
  32. {%- endif %}
  33. {%- if master.gitfs_password is defined %}
  34. gitfs_password: {{ master.gitfs_password }}
  35. {%- endif %}
  36. {%- if master.gitfs_insecure_auth is defined %}
  37. gitfs_insecure_auth: {{ master.gitfs_insecure_auth }}
  38. {%- endif %}
  39. {%- if master.gitfs_pubkey is defined %}
  40. gitfs_pubkey: {{ master.gitfs_pubkey }}
  41. {%- endif %}
  42. {%- if master.gitfs_privkey is defined %}
  43. gitfs_privkey: {{ master.gitfs_privkey }}
  44. {%- endif %}
  45. {%- if master.gitfs_passphrase is defined %}
  46. gitfs_passphrase: {{ master.gitfs_passphrase }}
  47. {%- endif %}
  48. {%- if master.gitfs_refspecs is defined %}
  49. gitfs_refspecs: {{ master.gitfs_refspecs }}
  50. {%- endif %}
  51. {%- if master.gitfs_disable_saltenv_mapping is defined %}
  52. gitfs_disable_saltenv_mapping: {{ master.gitfs_disable_saltenv_mapping }}
  53. {%- endif %}
  54. {%- if master.gitfs_ref_types is defined %}
  55. gitfs_ref_types: {{ master.gitfs_ref_types }}
  56. {%- endif %}
  57. {%- if master.gitfs_update_interval is defined %}
  58. gitfs_update_interval: {{ master.gitfs_update_interval }}
  59. {%- endif %}
  60. {%- if master.gitfs_remotes is defined %}
  61. gitfs_remotes:
  62. {%- for fs, fsparams in master.gitfs_remotes.items() %}
  63. {%- if fsparams.get('enabled', False) %}
  64. {%- if fsparams.params is defined %}
  65. - {{ fsparams.url }}:
  66. {%- for key, value in fsparams.params.iteritems() %}
  67. - {{ key }}: {{ value }}
  68. {%- endfor %}
  69. {%- else %}
  70. - {{ fsparams.url }}
  71. {%- endif %}
  72. {%- endif %}
  73. {%- endfor %}
  74. {%- endif %}
  75. {%- if master.system is defined %}
  76. file_roots:
  77. base:
  78. - {{ master.dir.files }}/{{ master.system.environment }}
  79. {%- for formula_name, formula in master.system.get('formula', {}).iteritems() %}
  80. - {{ master.dir.files }}/{{ master.system.environment }}/{{ formula_name }}
  81. {%- endfor %}
  82. {{ master.system.environment }}:
  83. - {{ master.dir.files }}/{{ master.system.environment }}
  84. {%- for formula_name, formula in master.system.get('formula', {}).iteritems() %}
  85. - {{ master.dir.files }}/{{ master.system.environment }}/{{ formula_name }}
  86. {%- endfor %}
  87. {%- else %}
  88. file_roots:
  89. {%- for environment_name, environment in master.get('environment', {}).iteritems() %}
  90. {%- if master.base_environment == environment_name %}
  91. base:
  92. - {{ master.dir.files }}/{{ environment_name }}
  93. {%- endif %}
  94. {{ environment_name }}:
  95. - {{ master.dir.files }}/{{ environment_name }}
  96. {%- endfor %}
  97. {%- endif %}
  98. pillar_opts: False
  99. pillar_safe_render_error: {{ master.pillar_safe_render_error }}
  100. {%- if master.accept_policy == 'open_mode' %}
  101. open_mode: True
  102. {%- endif %}
  103. {%- if master.accept_policy == 'auto_accept' %}
  104. auto_accept: True
  105. {%- endif %}
  106. {%- if master.max_event_size is defined %}
  107. max_event_size: {{ master.max_event_size }}
  108. {%- endif %}
  109. {%- if master.pillar.engine == 'salt' %}
  110. pillar_roots:
  111. base:
  112. - {{ master.pillar.get('salt', {}).get('path', '/srv/salt/pillar') }}
  113. {%- endif %}
  114. {%- if master.pillar.engine == 'architect' %}
  115. ext_pillar:
  116. - cmd_yaml: 'architect-salt-pillar %s'
  117. master_tops:
  118. ext_nodes: architect-salt-top
  119. {%- endif %}
  120. {%- if master.pillar.engine == 'reclass' or (master.pillar.engine == 'composite' and master.pillar.reclass is defined) %}
  121. reclass: &reclass
  122. storage_type: {{ master.pillar.get('reclass', {}).get('storage_type', 'yaml_fs') }}
  123. inventory_base_uri: {{ master.pillar.get('reclass', {}).get('inventory_base_uri', '/srv/salt/reclass') }}
  124. {# Additional options, for backward compatibility salt:master:pillar might not be defined #}
  125. {%- if master.pillar.reclass is defined %}
  126. {%- if master.pillar.reclass.reclass_source_path is defined %}
  127. reclass_source_path: {{ master.pillar.reclass.reclass_source_path }}
  128. {%- endif %}
  129. {%- if master.pillar.reclass.get('class_mappings', [])|length > 0 %}
  130. class_mappings:
  131. {%- for mapping in master.pillar.reclass.class_mappings %}
  132. - {{ mapping.target }} {{ mapping.class }}
  133. {%- endfor %}
  134. {%- endif %}
  135. {%- if master.pillar.reclass.get('propagate_pillar_data_to_reclass', False) == True %}
  136. propagate_pillar_data_to_reclass: {{ master.pillar.reclass.propagate_pillar_data_to_reclass }}
  137. {%- endif %}
  138. # Below options are not available in original reclass,
  139. # use fork with extensions from https://github.com/salt-formulas/reclass
  140. {%- if master.pillar.reclass.get('ignore_class_notfound', False) == True %}
  141. ignore_class_notfound: {{ master.pillar.reclass.ignore_class_notfound }}
  142. ignore_class_regexp: {{ master.pillar.reclass.ignore_class_regexp }}
  143. {%- endif %}
  144. {%- if master.pillar.reclass.allow_scalar_over_dict is defined %}
  145. allow_scalar_over_dict: {{ master.pillar.reclass.allow_scalar_over_dict }}
  146. {%- endif %}
  147. {%- if master.pillar.reclass.allow_scalar_over_list is defined %}
  148. allow_scalar_over_list: {{ master.pillar.reclass.allow_scalar_over_list }}
  149. {%- endif %}
  150. {%- if master.pillar.reclass.allow_list_over_scalar is defined %}
  151. allow_list_over_scalar: {{ master.pillar.reclass.allow_list_over_scalar }}
  152. {%- endif %}
  153. {%- if master.pillar.reclass.allow_dict_over_scalar is defined %}
  154. allow_dict_over_scalar: {{ master.pillar.reclass.allow_dict_over_scalar }}
  155. {%- endif %}
  156. {%- if master.pillar.reclass.allow_none_override is defined %}
  157. allow_none_override: {{ master.pillar.reclass.allow_none_override }}
  158. {%- endif %}
  159. {%- endif %}
  160. {%- endif %}
  161. {%- if master.pillar.engine == 'saltclass' or (master.pillar.engine == 'composite' and master.pillar.saltclass is defined ) %}
  162. saltclass: &saltclass
  163. path: {{ master.pillar.saltclass.get('path', '/srv/salt/saltclass') }}
  164. {%- endif %}
  165. {%- if master.pillar.engine in ['composite', 'reclass'] %}
  166. {# generate indexed list of ext_engines #}
  167. {# NONE: Might be rewritten, once proved to work properly, with filters: #}
  168. {# NONE: select('mapping')|selectattr('_index')|sort(attribute='_index') #}
  169. {%- set ext_engines = {} %}
  170. {%- for name,engine in master.pillar.iteritems() %}
  171. {%- if not engine is mapping %}{% continue %}{% endif %}
  172. {%- do engine.update({'name': engine.get('name', name) }) %}
  173. {%- set index = engine.get('index', '1')~'-'~name %}
  174. {%- do ext_engines.update({ index: engine }) %}
  175. {%- endfor %}
  176. {%- if ext_engines|length > 0 or master.pillar.engine == "reclass" %}
  177. ext_pillar:
  178. {%- if master.pillar.engine == 'reclass' %}
  179. {#- too keep backward compatibility, in case master.pillar.reclass is not defied at all #}
  180. - reclass: *reclass
  181. {%- endif %}
  182. {%- for name, engine in ext_engines|dictsort %}
  183. {%- if master.pillar.engine == 'composite' and engine.name == 'reclass' %}
  184. - reclass: *reclass
  185. {%- endif %}
  186. {%- if engine.name == 'saltclass' %}
  187. - saltclass: *saltclass
  188. {%- endif %}
  189. {%- if engine.name == 'nacl' %}
  190. - nacl: {}
  191. {%- endif %}
  192. {%- if engine.name == 'gpg' %}
  193. - gpg: {}
  194. {%- endif %}
  195. {%- endfor %}
  196. {%- endif %}
  197. {%- endif %}
  198. {%- if master.ext_pillars is defined %}
  199. {%- for _, ext_pillar in master.ext_pillars.items() %}
  200. - {{ ext_pillar.module }}: {{ ext_pillar.params }}
  201. {%- endfor %}
  202. {%- endif %}
  203. {%- if master.pillar.engine == 'reclass'
  204. or (master.pillar.engine == 'composite' and
  205. (master.pillar.saltclass is defined or
  206. master.pillar.reclass is defined )) %}
  207. master_tops:
  208. {%- if master.pillar.engine == 'reclass' or (master.pillar.engine == 'composite' and master.pillar.reclass is defined ) %}
  209. reclass: *reclass
  210. {%- endif %}
  211. {%- if master.pillar.engine == 'saltclass' or (master.pillar.engine == 'composite' and master.pillar.saltclass is defined ) %}
  212. saltclass: *saltclass
  213. {%- endif %}
  214. {%- endif %}
  215. {%- if master.log is defined %}
  216. {%- if master.log.level is defined %}
  217. log_level: {{ master.log.level }}
  218. {%- endif %}
  219. {%- if master.log.file is defined %}
  220. log_file: {{ master.log.file }}
  221. {%- endif %}
  222. {%- if master.log.level_logfile is defined %}
  223. log_level_logfile: {{ master.log.level_logfile }}
  224. {%- endif %}
  225. {%- endif %}
  226. {%- if pillar.salt.get('minion') %}
  227. {%- for handler in pillar.salt.minion.get("handlers", []) %}
  228. {%- if handler.engine == "udp"%}
  229. logstash_udp_handler:
  230. host: {{ handler.host }}
  231. port: {{ handler.port }}
  232. version: 1
  233. {%- endif %}
  234. {%- if handler.engine == "zmq"%}
  235. logstash_zmq_handler:
  236. address: tcp://{{ handler.host }}:{{ handler.port }}
  237. version: 1
  238. {%- endif %}
  239. {%- endfor %}
  240. {%- endif %}
  241. {%- if master.get('order_masters', False) %}
  242. order_masters: True
  243. {%- endif %}
  244. {%- if master.nacl is defined %}
  245. nacl.config:
  246. box_type: {{ master.nacl.get('box_type', 'sealedbox') }}
  247. {%- if master.nacl.sk is defined %}
  248. sk: {{ master.nacl.sk }}
  249. pk: {{ master.nacl.pk }}
  250. {%- else %}
  251. sk_file: {{ master.nacl.sk_file }}
  252. pk_file: {{ master.nacl.pk_file }}
  253. {%- endif %}
  254. {%- endif %}
  255. file_recv: {{ master.get('file_recv', False) }}
  256. id: {{ master.id | default(system.name~"."~system.domain) }}
  257. {#-
  258. vim: syntax=jinja
  259. -#}