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

157 行
4.3KB

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