Saltstack Official Salt Formula
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

198 rindas
6.7KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=jinja
  3. {%- macro deep_merge(a, b) %}
  4. {#- This whole `'dict' in x.__class__.__name__` mess is a
  5. workaround for the missing mapping test in CentOS 6's
  6. ancient Jinja2, see #193 #}
  7. {%- for k,v in b.iteritems() %}
  8. {%- if v is string or v is number %}
  9. {%- do a.update({ k: v }) %}
  10. {%- elif 'dict' not in v.__class__.__name__ %}
  11. {%- if a[k] is not defined %}
  12. {%- do a.update({ k: v }) %}
  13. {%- elif a[k] is iterable and 'dict' not in a[k].__class__.__name__ and
  14. a[k] is not string %}
  15. {%- do a.update({ k: v|list + a[k]|list}) %}
  16. {%- else %}
  17. {%- do a.update({ k: v }) %}
  18. {%- endif %}
  19. {%- elif 'dict' in v.__class__.__name__ %}
  20. {%- if a[k] is not defined %}
  21. {%- do a.update({ k: v }) %}
  22. {%- elif 'dict' in a[k].__class__.__name__ %}
  23. {%- do a.update({ k: v }) %}
  24. {%- else %}
  25. {%- do deep_merge(a[k], v) %}
  26. {%- endif %}
  27. {%- else %}
  28. {%- do a.update({ k: 'ERROR: case not contempled in merging!' }) %}
  29. {%- endif %}
  30. {%- endfor %}
  31. {%- endmacro %}
  32. {## Start with defaults from defaults.yaml ##}
  33. {% import_yaml "salt/defaults.yaml" as default_settings %}
  34. {##
  35. Setup variable using grains['os_family'] based logic, only add key:values here
  36. that differ from whats in defaults.yaml
  37. ##}
  38. {% set osrelease = salt['grains.get']('osrelease') %}
  39. {% set salt_release = salt['pillar.get']('salt:release', 'latest') %}
  40. {% set os_family_map = salt['grains.filter_by']({
  41. 'Debian': {
  42. 'pkgrepo': 'deb http://repo.saltstack.com/apt/' +
  43. salt['grains.get']('os')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease) + '/amd64/' + salt_release + ' ' + salt['grains.get']('oscodename') + ' main',
  44. 'key_url': 'https://repo.saltstack.com/apt/' + salt['grains.get']('os')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease) + '/amd64/' + salt_release + '/SALTSTACK-GPG-KEY.pub',
  45. 'libgit2': 'libgit2-22',
  46. 'gitfs': {
  47. 'pygit2': {
  48. 'install_from_source': True,
  49. 'version': '0.22.1',
  50. 'git': {
  51. 'require_state': False,
  52. 'install_from_package': 'git',
  53. },
  54. 'libgit2': {
  55. 'install_from_source': False,
  56. },
  57. },
  58. },
  59. },
  60. 'RedHat': {
  61. 'pkgrepo': 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/' + salt_release,
  62. 'key_url': 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/' + salt_release + '/SALTSTACK-GPG-KEY.pub',
  63. 'pygit2': salt['grains.filter_by']({
  64. 'Fedora': 'python2-pygit2',
  65. 'default': 'python-pygit2',
  66. }, grain='os'),
  67. 'python_git': 'GitPython',
  68. 'gitfs': {
  69. 'pygit2': {
  70. 'install_from_source': False,
  71. 'git': {
  72. 'require_state': False,
  73. 'install_from_package': 'git',
  74. },
  75. },
  76. },
  77. 'master': {
  78. 'gitfs_provider': 'pygit2'
  79. },
  80. },
  81. 'Suse': {},
  82. 'Gentoo': {
  83. 'salt_master': 'app-admin/salt',
  84. 'salt_minion': 'app-admin/salt',
  85. 'salt_syndic': 'app-admin/salt',
  86. 'salt_api': 'app-admin/salt',
  87. 'salt_cloud': 'app-admin/salt',
  88. },
  89. 'Arch': {
  90. 'salt_master': 'salt',
  91. 'salt_minion': 'salt',
  92. 'salt_syndic': 'salt',
  93. 'salt_cloud': 'salt',
  94. 'salt_api': 'salt',
  95. 'salt_ssh': 'salt',
  96. 'pygit2': 'python2-pygit2',
  97. 'libgit2': 'libgit2',
  98. },
  99. 'Alpine': {
  100. 'salt_master': 'salt-master',
  101. 'salt_minion': 'salt-minion',
  102. 'salt_syndic': 'salt-syndic',
  103. 'salt_cloud': 'salt-cloud',
  104. 'salt_api': 'salt-api',
  105. 'salt_ssh': 'salt-ssh',
  106. 'pygit2': 'py2-pygit2',
  107. 'libgit2': 'libgit2',
  108. },
  109. 'FreeBSD': {
  110. 'salt_master': 'py27-salt',
  111. 'salt_minion': 'py27-salt',
  112. 'salt_syndic': 'py27-salt',
  113. 'salt_cloud': 'py27-salt',
  114. 'salt_api': 'py27-salt',
  115. 'salt_ssh': 'py27-salt',
  116. 'python_git': 'py27-GitPython',
  117. 'pygit2': 'py27-pygit2',
  118. 'config_path': '/usr/local/etc/salt',
  119. 'minion_service': 'salt_minion',
  120. 'master_service': 'salt_master',
  121. 'api_service': 'salt_api',
  122. 'syndic_service': 'salt_syndic',
  123. },
  124. 'OpenBSD': {
  125. 'salt_master': 'salt',
  126. 'salt_minion': 'salt',
  127. 'salt_syndic': 'salt',
  128. 'salt_cloud': 'salt',
  129. 'salt_api': 'salt',
  130. 'salt_ssh': 'salt',
  131. 'config_path': '/etc/salt',
  132. 'minion_service': 'salt_minion',
  133. 'master_service': 'salt_master',
  134. 'python_git': 'py-GitPython',
  135. },
  136. 'Windows': {
  137. 'salt_minion': 'saltstack.minion',
  138. 'config_path': 'C:\salt\conf',
  139. 'minion_service': 'salt-minion',
  140. },
  141. }, merge=salt['grains.filter_by']({
  142. 'Ubuntu': {
  143. 'pkgrepo': 'deb http://repo.saltstack.com/apt/' +
  144. salt['grains.get']('os')|lower + '/' + osrelease + '/amd64/' + salt_release + ' ' + salt['grains.get']('oscodename') + ' main',
  145. 'key_url': 'https://repo.saltstack.com/apt/' + salt['grains.get']('os')|lower + '/' + osrelease + '/amd64/' + salt_release + '/SALTSTACK-GPG-KEY.pub',
  146. 'pygit2': 'python-pygit2',
  147. 'gitfs': {
  148. 'pygit2': {
  149. 'install_from_source': False,
  150. 'git': {
  151. 'require_state': False,
  152. 'install_from_package': None,
  153. },
  154. },
  155. },
  156. },
  157. 'Raspbian': {
  158. 'pkgrepo': 'deb http://repo.saltstack.com/apt/' +
  159. salt['grains.get']('os_family')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease) + '/armhf/' + salt_release + ' ' + salt['grains.get']('oscodename') + ' main',
  160. 'key_url': 'https://repo.saltstack.com/apt/' + salt['grains.get']('os_family')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease) + '/armhf/' + salt_release + '/SALTSTACK-GPG-KEY.pub',
  161. },
  162. 'SmartOS': {
  163. 'salt_master': 'salt',
  164. 'salt_minion': 'salt',
  165. 'salt_syndic': 'salt',
  166. 'salt_cloud': 'salt',
  167. 'salt_api': 'salt',
  168. 'salt_ssh': 'salt',
  169. 'minion_service': 'salt:minion',
  170. 'master_service': 'salt:master',
  171. 'python_dulwich': 'py27-dulwich',
  172. 'gitfs': {
  173. 'dulwich': {
  174. 'install_from_source': False,
  175. }
  176. },
  177. 'config_path': '/opt/local/etc/salt',
  178. 'master': {
  179. 'gitfs_provider': 'dulwich'
  180. },
  181. }
  182. }, grain='os', merge=salt['pillar.get']('salt:lookup')))
  183. %}
  184. {## Merge the flavor_map to the default settings ##}
  185. {% do deep_merge(default_settings.salt,os_family_map) %}
  186. {## Merge in salt:lookup pillar ##}
  187. {% set salt_settings = salt['pillar.get'](
  188. 'salt',
  189. default=default_settings.salt,
  190. merge=True)
  191. %}