New version of salt-formula from Saltstack
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

158 lines
4.4KB

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