New version of salt-formula from Saltstack
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

209 lines
5.7KB

  1. {%- from "salt/map.jinja" import minion with context -%}
  2. {%- from "linux/map.jinja" import system with context -%}
  3. {%- if minion.masters is defined -%}
  4. master:
  5. {%- for master in minion.masters %}
  6. - {{ master.host }}
  7. {%- endfor %}
  8. {%- if minion.get('master_type', 'default') == "failover" %}
  9. master_type: failover
  10. retry_dns: 0
  11. master_shuffle: True
  12. master_alive_interval: 60
  13. {%- endif %}
  14. {%- else %}
  15. master: {{ minion.master.host }}
  16. {%- endif %}
  17. id: {{ minion.id | default(system.name~"."~system.domain) }}
  18. {%- set opt_list=[
  19. 'acceptance_wait_time',
  20. 'acceptance_wait_time_max',
  21. 'auth_timeout',
  22. 'cachedir',
  23. 'grains_refresh_every',
  24. 'master_alive_interval',
  25. 'master_tries',
  26. 'max_event_size',
  27. 'random_reauth_delay',
  28. 'recon_default',
  29. 'recon_max',
  30. 'tcp_keepalive',
  31. 'tcp_keepalive_cnt',
  32. 'tcp_keepalive_idle',
  33. 'tcp_keepalive_intvl'
  34. ] %}
  35. {%- for opt in opt_list %}
  36. {%- if minion.get(opt) %}
  37. {{ opt }}: {{ minion.get(opt) }}
  38. {%- endif %}
  39. {%- endfor %}
  40. {%- if minion.grains_cache is defined %}
  41. grains_cache: {{ minion.grains_cache }}
  42. {%- endif %}
  43. {%- if minion.recon_randomize is defined %}
  44. recon_randomize: {{ minion.recon_randomize }}
  45. {%- endif %}
  46. {%- if minion.rejected_retry is defined %}
  47. rejected_retry: {{ minion.rejected_retry }}
  48. {%- endif %}
  49. {%- set excluded_keys = ('master', 'system', 'public_keys', 'private_keys', 'known_hosts', '__reclass__', '_secret', '_param') %}
  50. grains:
  51. {%- if minion.get('manage_roles', True) %}
  52. roles:
  53. {%- for key, value in pillar.items() %}
  54. {%- if key not in excluded_keys %}
  55. {%- for subkey, subvalue in value.iteritems() %}
  56. {%- if subvalue.enabled is defined and subvalue.enabled %}
  57. - {{key}}.{{ subkey }}
  58. {%- endif %}
  59. {%- endfor %}
  60. {%- endif %}
  61. {%- endfor %}
  62. {%- endif %}
  63. services:
  64. {%- for key, value in pillar.items() %}
  65. {%- if key not in excluded_keys %}
  66. - {{key}}
  67. {%- endif %}
  68. {%- endfor %}
  69. grains_dirs:
  70. - /var/lib/salt/grains
  71. {%- if minion.mine is defined %}
  72. mine_functions:
  73. {%- for salt_module, salt_functions in minion.mine.module.iteritems() %}
  74. {{ salt_module }}: {{ salt_functions }}
  75. {%- endfor %}
  76. mine_interval: {{ minion.mine.get('interval', 30) }}
  77. {%- endif %}
  78. {%- if minion.log is defined %}
  79. {%- if minion.log.level is defined %}
  80. log_level: {{ minion.log.level }}
  81. {%- endif %}
  82. {%- if minion.log.file is defined %}
  83. log_file: {{ minion.log.file }}
  84. {%- endif %}
  85. {%- if minion.log.level_logfile is defined %}
  86. log_level_logfile: {{ minion.log.level_logfile }}
  87. {%- endif %}
  88. {%- endif %}
  89. state_output: {{ minion.get('log', {}).get('state_output', 'changes') }}
  90. {%- if minion.get('proxy', {}).get('host', "") != "" %}
  91. proxy_host: {{ minion.proxy.host }}
  92. proxy_port: {{ minion.proxy.port }}
  93. {%- endif %}
  94. {%- if minion.backend is defined %}
  95. backend: {{ minion.backend }}
  96. {%- endif %}
  97. {%- if minion.sentry is defined %}
  98. sentry_handler:
  99. {% for server in minion.sentry.servers %}
  100. servers:
  101. - {{ server }}
  102. {% endfor %}
  103. project: {{ pillar.salt.minion.sentry.project }}
  104. public_key: {{ pillar.salt.minion.sentry.public_key }}
  105. secret_key: {{ pillar.salt.minion.sentry.secret_key }}
  106. {% if pillar.salt.minion.sentry.log_level is defined %}
  107. log_level: {{ pillar.salt.minion.sentry.log_level }}
  108. {%- endif %}
  109. {%- endif %}
  110. {%- if pillar.get('galera', {}).get('master', {}).get('enabled', False) %}
  111. {%- from "galera/map.jinja" import master with context %}
  112. mysql.unix_socket: {{ master.socket }}
  113. mysql.user: '{{ pillar.galera.master.admin.user }}'
  114. mysql.pass: '{{ pillar.galera.master.admin.password }}'
  115. mysql.db: 'mysql'
  116. mysql.charset: 'utf8'
  117. {%- elif pillar.get('galera', {}).get('slave', {}).get('enabled', False) %}
  118. {%- from "galera/map.jinja" import slave with context %}
  119. mysql.unix_socket: {{ slave.socket }}
  120. mysql.user: '{{ pillar.galera.slave.admin.user }}'
  121. mysql.pass: '{{ pillar.galera.slave.admin.password }}'
  122. mysql.db: 'mysql'
  123. mysql.charset: 'utf8'
  124. {%- elif pillar.get('mysql', {}).get('server', {}).get('enabled', False) %}
  125. mysql.unix_socket: /var/run/mysqld/mysqld.sock
  126. {%- if pillar.mysql.server.admin is defined %}
  127. mysql.user: '{{ pillar.mysql.server.admin.user }}'
  128. mysql.pass: '{{ pillar.mysql.server.admin.password }}'
  129. {%- else %}
  130. mysql.user: 'root'
  131. mysql.pass: ''
  132. {%- endif %}
  133. mysql.db: 'mysql'
  134. mysql.charset: 'utf8'
  135. {%- endif %}
  136. {%- if pillar.get('mongodb', {}).server is defined %}
  137. mongodb.host: 'localhost'
  138. mongodb.port: {{ pillar.mongodb.server.bind.port }}
  139. {%- if pillar.mongodb.server.get('admin', {}).user is defined %}
  140. mongodb.user: '{{ pillar.mongodb.server.admin.user }}'
  141. {%- endif %}
  142. {%- if pillar.mongodb.server.get('admin', {}).password is defined %}
  143. mongodb.password: '{{ pillar.mongodb.server.admin.password }}'
  144. {%- endif %}
  145. {%- endif %}
  146. {%- if pillar.get('postgresql', {}).server is defined %}
  147. postgres.user: 'postgres'
  148. postgres.pass: ''
  149. postgres.db: 'template1'
  150. {%- endif %}
  151. {%- if pillar.get('gitlab', {}).client is defined %}
  152. gitlab.url: 'https://{{ pillar.gitlab.client.server.host }}/'
  153. gitlab.token: '{{ pillar.gitlab.client.server.token }}'
  154. {%- elif pillar.get('gitlab', {}).server is defined %}
  155. gitlab.url: 'https://{{ pillar.gitlab.server.server_name }}/'
  156. gitlab.token: '{{ pillar.gitlab.server.get('token', 'Set token in pillar') }}'
  157. {%- endif %}
  158. {%- if pillar.get('keystone', {}).get('server', {'enabled': False } ).enabled %}
  159. keystone.token: '{{ pillar.keystone.server.service_token }}'
  160. keystone.endpoint: 'http://{{ pillar.keystone.server.bind.private_address }}:{{ pillar.keystone.server.bind.private_port }}/v2.0'
  161. {%- endif %}
  162. {%- for handler in pillar.salt.minion.get("handlers", []) %}
  163. {%- if handler.engine == "udp"%}
  164. logstash_udp_handler:
  165. host: {{ handler.host }}
  166. port: {{ handler.port }}
  167. version: 1
  168. {%- endif %}
  169. {%- if handler.engine == "zmq"%}
  170. logstash_zmq_handler:
  171. address: tcp://{{ handler.host }}:{{ handler.port }}
  172. version: 1
  173. {%- endif %}
  174. {%- endfor %}
  175. {#-
  176. vim: syntax=jinja
  177. -#}