New version of salt-formula from Saltstack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
7.7KB

  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.system is defined %}
  19. file_roots:
  20. base:
  21. - {{ master.dir.files }}/{{ master.system.environment }}
  22. {%- for formula_name, formula in master.system.get('formula', {}).iteritems() %}
  23. - {{ master.dir.files }}/{{ master.system.environment }}/{{ formula_name }}
  24. {%- endfor %}
  25. {{ master.system.environment }}:
  26. - {{ master.dir.files }}/{{ master.system.environment }}
  27. {%- for formula_name, formula in master.system.get('formula', {}).iteritems() %}
  28. - {{ master.dir.files }}/{{ master.system.environment }}/{{ formula_name }}
  29. {%- endfor %}
  30. {%- else %}
  31. file_roots:
  32. {%- for environment_name, environment in master.get('environment', {}).iteritems() %}
  33. {%- if master.base_environment == environment_name %}
  34. base:
  35. - {{ master.dir.files }}/{{ environment_name }}
  36. {%- endif %}
  37. {{ environment_name }}:
  38. - {{ master.dir.files }}/{{ environment_name }}
  39. {%- endfor %}
  40. {%- endif %}
  41. pillar_opts: False
  42. pillar_safe_render_error: {{ master.pillar_safe_render_error }}
  43. {%- if master.accept_policy == 'open_mode' %}
  44. open_mode: True
  45. {%- endif %}
  46. {%- if master.accept_policy == 'auto_accept' %}
  47. auto_accept: True
  48. {%- endif %}
  49. {%- if master.max_event_size is defined %}
  50. max_event_size: {{ master.max_event_size }}
  51. {%- endif %}
  52. {%- if master.pillar.engine == 'salt' %}
  53. pillar_roots:
  54. base:
  55. - {{ master.pillar.get('salt', {}).get('path', '/srv/salt/pillar') }}
  56. {%- endif %}
  57. {%- if master.pillar.engine == 'architect' %}
  58. ext_pillar:
  59. - cmd_yaml: 'architect-salt-pillar %s'
  60. master_tops:
  61. ext_nodes: architect-salt-top
  62. {%- endif %}
  63. {%- if master.pillar.engine == 'reclass' or (master.pillar.engine == 'composite' and master.pillar.reclass is defined) %}
  64. reclass: &reclass
  65. storage_type: {{ master.pillar.get('reclass', {}).get('storage_type', 'yaml_fs') }}
  66. inventory_base_uri: {{ master.pillar.get('reclass', {}).get('inventory_base_uri', '/srv/salt/reclass') }}
  67. {# Additional options, for backward compatibility salt:master:pillar might not be defined #}
  68. {%- if master.pillar.reclass is defined %}
  69. {%- if master.pillar.reclass.reclass_source_path is defined %}
  70. reclass_source_path: {{ master.pillar.reclass.reclass_source_path }}
  71. {%- endif %}
  72. {%- if master.pillar.reclass.get('class_mappings', [])|length > 0 %}
  73. class_mappings:
  74. {%- for mapping in master.pillar.reclass.class_mappings %}
  75. - {{ mapping.target }} {{ mapping.class }}
  76. {%- endfor %}
  77. {%- endif %}
  78. {%- if master.pillar.reclass.get('propagate_pillar_data_to_reclass', False) == True %}
  79. propagate_pillar_data_to_reclass: {{ master.pillar.reclass.propagate_pillar_data_to_reclass }}
  80. {%- endif %}
  81. # Below options are not available in original reclass,
  82. # use fork with extensions from https://github.com/salt-formulas/reclass
  83. {%- if master.pillar.reclass.get('ignore_class_notfound', False) == True %}
  84. ignore_class_notfound: {{ master.pillar.reclass.ignore_class_notfound }}
  85. ignore_class_regexp: {{ master.pillar.reclass.ignore_class_regexp }}
  86. {%- endif %}
  87. {%- if master.pillar.reclass.allow_scalar_over_dict is defined %}
  88. allow_scalar_over_dict: {{ master.pillar.reclass.allow_scalar_over_dict }}
  89. {%- endif %}
  90. {%- if master.pillar.reclass.allow_scalar_over_list is defined %}
  91. allow_scalar_over_list: {{ master.pillar.reclass.allow_scalar_over_list }}
  92. {%- endif %}
  93. {%- if master.pillar.reclass.allow_list_over_scalar is defined %}
  94. allow_list_over_scalar: {{ master.pillar.reclass.allow_list_over_scalar }}
  95. {%- endif %}
  96. {%- if master.pillar.reclass.allow_dict_over_scalar is defined %}
  97. allow_dict_over_scalar: {{ master.pillar.reclass.allow_dict_over_scalar }}
  98. {%- endif %}
  99. {%- if master.pillar.reclass.allow_none_override is defined %}
  100. allow_none_override: {{ master.pillar.reclass.allow_none_override }}
  101. {%- endif %}
  102. {%- endif %}
  103. {%- endif %}
  104. {%- if master.pillar.engine == 'saltclass' or (master.pillar.engine == 'composite' and master.pillar.saltclass is defined ) %}
  105. saltclass: &saltclass
  106. path: {{ master.pillar.saltclass.get('path', '/srv/salt/saltclass') }}
  107. {%- endif %}
  108. {%- if master.pillar.engine in ['composite', 'reclass'] %}
  109. {# generate indexed list of ext_engines #}
  110. {# NONE: Might be rewritten, once proved to work properly, with filters: #}
  111. {# NONE: select('mapping')|selectattr('_index')|sort(attribute='_index') #}
  112. {%- set ext_engines = {} %}
  113. {%- for name,engine in master.pillar.iteritems() %}
  114. {%- if not engine is mapping %}{% continue %}{% endif %}
  115. {%- do engine.update({'name': engine.get('name', name) }) %}
  116. {%- set index = engine.get('index', '1')~'-'~name %}
  117. {%- do ext_engines.update({ index: engine }) %}
  118. {%- endfor %}
  119. {%- if ext_engines|length > 0 or master.pillar.engine == "reclass" %}
  120. ext_pillar:
  121. {%- if master.pillar.engine == 'reclass' %}
  122. {#- too keep backward compatibility, in case master.pillar.reclass is not defied at all #}
  123. - reclass: *reclass
  124. {%- endif %}
  125. {%- for name, engine in ext_engines|dictsort %}
  126. {%- if master.pillar.engine == 'composite' and engine.name == 'reclass' %}
  127. - reclass: *reclass
  128. {%- endif %}
  129. {%- if engine.name == 'saltclass' %}
  130. - saltclass: *saltclass
  131. {%- endif %}
  132. {%- if engine.name == 'nacl' %}
  133. - nacl: {}
  134. {%- endif %}
  135. {%- if engine.name == 'gpg' %}
  136. - gpg: {}
  137. {%- endif %}
  138. {%- endfor %}
  139. {%- endif %}
  140. {%- endif %}
  141. {%- if master.ext_pillars is defined %}
  142. {%- for _, ext_pillar in master.ext_pillars.items() %}
  143. - {{ ext_pillar.module }}: {{ ext_pillar.params }}
  144. {%- endfor %}
  145. {%- endif %}
  146. {%- if master.pillar.engine == 'reclass'
  147. or (master.pillar.engine == 'composite' and
  148. (master.pillar.saltclass is defined or
  149. master.pillar.reclass is defined )) %}
  150. master_tops:
  151. {%- if master.pillar.engine == 'reclass' or (master.pillar.engine == 'composite' and master.pillar.reclass is defined ) %}
  152. reclass: *reclass
  153. {%- endif %}
  154. {%- if master.pillar.engine == 'saltclass' or (master.pillar.engine == 'composite' and master.pillar.saltclass is defined ) %}
  155. saltclass: *saltclass
  156. {%- endif %}
  157. {%- endif %}
  158. {%- if master.log is defined %}
  159. {%- if master.log.level is defined %}
  160. log_level: {{ master.log.level }}
  161. {%- endif %}
  162. {%- if master.log.file is defined %}
  163. log_file: {{ master.log.file }}
  164. {%- endif %}
  165. {%- if master.log.level_logfile is defined %}
  166. log_level_logfile: {{ master.log.level_logfile }}
  167. {%- endif %}
  168. {%- endif %}
  169. {%- if pillar.salt.get('minion') %}
  170. {%- for handler in pillar.salt.minion.get("handlers", []) %}
  171. {%- if handler.engine == "udp"%}
  172. logstash_udp_handler:
  173. host: {{ handler.host }}
  174. port: {{ handler.port }}
  175. version: 1
  176. {%- endif %}
  177. {%- if handler.engine == "zmq"%}
  178. logstash_zmq_handler:
  179. address: tcp://{{ handler.host }}:{{ handler.port }}
  180. version: 1
  181. {%- endif %}
  182. {%- endfor %}
  183. {%- endif %}
  184. {%- if master.get('order_masters', False) %}
  185. order_masters: True
  186. {%- endif %}
  187. {%- if master.nacl is defined %}
  188. nacl.config:
  189. box_type: {{ master.nacl.get('box_type', 'sealedbox') }}
  190. {%- if master.nacl.sk is defined %}
  191. sk: {{ master.nacl.sk }}
  192. pk: {{ master.nacl.pk }}
  193. {%- else %}
  194. sk_file: {{ master.nacl.sk_file }}
  195. pk_file: {{ master.nacl.pk_file }}
  196. {%- endif %}
  197. {%- endif %}
  198. file_recv: {{ master.get('file_recv', False) }}
  199. id: {{ master.id | default(system.name~"."~system.domain) }}
  200. {#-
  201. vim: syntax=jinja
  202. -#}