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.

9 年之前
8 年之前
8 年之前
9 年之前
9 年之前
9 年之前
9 年之前
8 年之前
9 年之前
8 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. -#}