Saltstack Official Salt Formula
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.

241 lines
7.8KB

  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.items() %}
  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. {# All minor releases appear in an `archive` sub-directory #}
  41. {% if salt_release.split('.')|length >= 3 %}
  42. {% set salt_release = 'archive/' ~ salt_release %}
  43. {% endif %}
  44. {% set os_family_map = salt['grains.filter_by']({
  45. 'Debian': {
  46. 'pkgrepo': 'deb http://repo.saltstack.com/apt/' +
  47. salt['grains.get']('os')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease)|string + '/amd64/' + salt_release + ' ' + salt['grains.get']('oscodename') + ' main',
  48. 'key_url': 'https://repo.saltstack.com/apt/' + salt['grains.get']('os')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease)|string + '/amd64/' + salt_release + '/SALTSTACK-GPG-KEY.pub',
  49. 'libgit2': 'libgit2-22',
  50. 'pyinotify': 'python-pyinotify',
  51. 'gitfs': {
  52. 'pygit2': {
  53. 'install_from_source': True,
  54. 'version': '0.22.1',
  55. 'git': {
  56. 'require_state': False,
  57. 'install_from_package': 'git',
  58. },
  59. 'libgit2': {
  60. 'install_from_source': False,
  61. },
  62. },
  63. },
  64. },
  65. 'RedHat': {
  66. 'pkgrepo': 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/' + salt_release,
  67. 'key_url': 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/' + salt_release + '/SALTSTACK-GPG-KEY.pub',
  68. 'pygit2': salt['grains.filter_by']({
  69. 'Fedora': 'python2-pygit2',
  70. 'default': 'python-pygit2',
  71. }, grain='os'),
  72. 'python_git': 'GitPython',
  73. 'gitfs': {
  74. 'gitpython': {
  75. 'install_from_source': False,
  76. },
  77. 'pygit2': {
  78. 'install_from_source': False,
  79. 'git': {
  80. 'require_state': False,
  81. 'install_from_package': 'git',
  82. },
  83. },
  84. },
  85. 'master': {
  86. 'gitfs_provider': 'pygit2'
  87. },
  88. },
  89. 'Suse': {
  90. 'pygit2': 'python-pygit2',
  91. 'pyinotify': 'python-pyinotify',
  92. 'gitfs': {
  93. 'pygit2': {
  94. 'install_from_source': False,
  95. 'git': {
  96. 'require_state': False,
  97. 'install_from_package': 'git',
  98. },
  99. },
  100. },
  101. 'master': {
  102. 'gitfs_provider': 'pygit2'
  103. },
  104. },
  105. 'Gentoo': {
  106. 'salt_master': 'app-admin/salt',
  107. 'salt_minion': 'app-admin/salt',
  108. 'salt_syndic': 'app-admin/salt',
  109. 'salt_api': 'app-admin/salt',
  110. 'salt_cloud': 'app-admin/salt',
  111. 'pyinotify': 'dev-python/pyinotify',
  112. },
  113. 'Arch': {
  114. 'salt_master': 'salt',
  115. 'salt_minion': 'salt',
  116. 'salt_syndic': 'salt',
  117. 'salt_cloud': 'salt',
  118. 'salt_api': 'salt',
  119. 'salt_ssh': 'salt',
  120. 'python_git': 'python2-gitpython',
  121. 'pygit2': 'python2-pygit2',
  122. 'libgit2': 'libgit2',
  123. 'pyinotify': 'python2-pyinotify',
  124. },
  125. 'Alpine': {
  126. 'salt_master': 'salt-master',
  127. 'salt_minion': 'salt-minion',
  128. 'salt_syndic': 'salt-syndic',
  129. 'salt_cloud': 'salt-cloud',
  130. 'salt_api': 'salt-api',
  131. 'salt_ssh': 'salt-ssh',
  132. 'pygit2': 'py2-pygit2',
  133. 'libgit2': 'libgit2',
  134. },
  135. 'FreeBSD': {
  136. 'salt_master': 'py27-salt',
  137. 'salt_minion': 'py27-salt',
  138. 'salt_syndic': 'py27-salt',
  139. 'salt_cloud': 'py27-salt',
  140. 'salt_api': 'py27-salt',
  141. 'salt_ssh': 'py27-salt',
  142. 'python_git': 'py27-GitPython',
  143. 'pygit2': 'py27-pygit2',
  144. 'config_path': '/usr/local/etc/salt',
  145. 'minion_service': 'salt_minion',
  146. 'master_service': 'salt_master',
  147. 'api_service': 'salt_api',
  148. 'syndic_service': 'salt_syndic',
  149. },
  150. 'OpenBSD': {
  151. 'salt_master': 'salt',
  152. 'salt_minion': 'salt',
  153. 'salt_syndic': 'salt',
  154. 'salt_cloud': 'salt',
  155. 'salt_api': 'salt',
  156. 'salt_ssh': 'salt',
  157. 'config_path': '/etc/salt',
  158. 'minion_service': 'salt_minion',
  159. 'master_service': 'salt_master',
  160. 'python_git': 'py-GitPython',
  161. },
  162. 'Windows': {
  163. 'salt_minion': 'salt-minion',
  164. 'config_path': 'C:\salt\conf',
  165. 'minion_service': 'salt-minion',
  166. },
  167. 'MacOS': {
  168. 'salt_minion': 'com.saltstack.salt',
  169. 'salt_minion_pkg_source': '',
  170. 'salt_minion_pkg_hash': '',
  171. 'config_path': '/private/etc/salt',
  172. 'minion_service': 'com.saltstack.salt.minion',
  173. },
  174. }, merge=salt['grains.filter_by']({
  175. 'Ubuntu': {
  176. 'pkgrepo': 'deb http://repo.saltstack.com/apt/' +
  177. salt['grains.get']('os')|lower + '/' + osrelease + '/amd64/' + salt_release + ' ' + salt['grains.get']('oscodename') + ' main',
  178. 'key_url': 'https://repo.saltstack.com/apt/' + salt['grains.get']('os')|lower + '/' + osrelease + '/amd64/' + salt_release + '/SALTSTACK-GPG-KEY.pub',
  179. 'pygit2': 'python-pygit2',
  180. 'gitfs': {
  181. 'pygit2': {
  182. 'install_from_source': False,
  183. 'git': {
  184. 'require_state': False,
  185. 'install_from_package': None,
  186. },
  187. },
  188. },
  189. },
  190. 'Raspbian': {
  191. 'pkgrepo': 'deb http://repo.saltstack.com/apt/' +
  192. salt['grains.get']('os_family')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease)|string + '/armhf/' + salt_release + ' ' + salt['grains.get']('oscodename') + ' main',
  193. 'key_url': 'https://repo.saltstack.com/apt/' + salt['grains.get']('os_family')|lower + '/' + salt['grains.get']('osmajorrelease', osrelease)|string + '/armhf/' + salt_release + '/SALTSTACK-GPG-KEY.pub',
  194. },
  195. 'SmartOS': {
  196. 'salt_master': 'salt',
  197. 'salt_minion': 'salt',
  198. 'salt_syndic': 'salt',
  199. 'salt_cloud': 'salt',
  200. 'salt_api': 'salt',
  201. 'salt_ssh': 'salt',
  202. 'minion_service': 'salt:minion',
  203. 'master_service': 'salt:master',
  204. 'api_service': 'salt:api',
  205. 'python_dulwich': 'py27-dulwich',
  206. 'gitfs': {
  207. 'dulwich': {
  208. 'install_from_source': False,
  209. }
  210. },
  211. 'config_path': '/opt/local/etc/salt',
  212. 'master': {
  213. 'gitfs_provider': 'dulwich'
  214. },
  215. }
  216. }, grain='os', merge=salt['pillar.get']('salt:lookup')))
  217. %}
  218. {## Merge the flavor_map to the default settings ##}
  219. {% do deep_merge(default_settings.salt,os_family_map) %}
  220. {## Merge in salt pillar ##}
  221. {% set salt_settings = salt['pillar.get'](
  222. 'salt',
  223. default=default_settings.salt,
  224. merge=True)
  225. %}
  226. {## Merge in salt_formulas pillar ##}
  227. {% set formulas_settings = salt['pillar.get'](
  228. 'salt_formulas',
  229. default=default_settings.salt_formulas,
  230. merge=True)
  231. %}