New version of salt-formula from Saltstack
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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