New version of salt-formula from Saltstack
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

hace 9 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. {%- from "salt/map.jinja" import master with context %}
  2. {%- if master.enabled %}
  3. include:
  4. - git.client
  5. - salt.master.service
  6. {%- if master.system is defined %}
  7. salt_env_{{ master.system.environment }}_dirs:
  8. file.directory:
  9. - names:
  10. - /srv/salt/env/{{ master.system.environment }}/_modules
  11. - /srv/salt/env/{{ master.system.environment }}/_states
  12. - /srv/salt/env/{{ master.system.environment }}/_grains
  13. - /srv/salt/env/{{ master.system.environment }}
  14. - makedirs: True
  15. {%- for grain_name, grain in master.system.get('grain', {}).iteritems() %}
  16. {%- if grain.source == 'git' %}
  17. salt_master_{{ master.system.environment }}_{{ grain_name }}_grain_source:
  18. git.latest:
  19. - name: {{ grain.address }}
  20. - target: /srv/salt/env/{{ master.system.environment }}/_extra/grain_{{ grain_name }}
  21. - rev: {{ grain.revision }}
  22. - require:
  23. - file: salt_env_{{ master.system.environment }}_dirs
  24. - pkg: git_packages
  25. /srv/salt/env/{{ master.system.environment }}/_grains/{{ grain_name }}.py:
  26. file.symlink:
  27. - target: /srv/salt/env/{{ master.system.environment }}/_extra/grain_{{ grain_name }}/{{ grain_name }}.py
  28. - require:
  29. - git: salt_master_{{ master.system.environment }}_{{ grain_name }}_grain_source
  30. {%- endif %}
  31. {%- endfor %}
  32. {%- for state_name, state in master.system.get('state', {}).iteritems() %}
  33. {%- if state.source == 'git' %}
  34. salt_master_{{ master.system.environment }}_{{ state_name }}_state_source:
  35. git.latest:
  36. - name: {{ state.address }}
  37. - target: /srv/salt/env/{{ master.system.environment }}/_extra/state_{{ state_name }}
  38. - rev: {{ state.revision }}
  39. - require:
  40. - file: salt_env_{{ master.system.environment }}_dirs
  41. - pkg: git_packages
  42. /srv/salt/env/{{ master.system.environment }}/_modules/{{ state_name }}.py:
  43. file.symlink:
  44. - target: /srv/salt/env/{{ master.system.environment }}/_extra/state_{{ state_name }}/modules/{{ state_name }}.py
  45. - require:
  46. - git: salt_master_{{ master.system.environment }}_{{ state_name }}_state_source
  47. /srv/salt/env/{{ master.system.environment }}/_states/{{ state_name }}.py:
  48. file.symlink:
  49. - target: /srv/salt/env/{{ master.system.environment }}/_extra/state_{{ state_name }}/states/{{ state_name }}.py
  50. - require:
  51. - git: salt_master_{{ master.system.environment }}_{{ state_name }}_state_source
  52. {%- endif %}
  53. {%- endfor %}
  54. {%- for formula_name, formula in master.system.get('formula', {}).iteritems() %}
  55. {%- if formula.source == 'git' %}
  56. salt_master_{{ master.system.environment }}_{{ formula_name }}_formula_source:
  57. git.latest:
  58. - name: {{ formula.address }}
  59. - target: /srv/salt/env/{{ master.system.environment }}/{{ formula_name }}
  60. - rev: {{ formula.revision }}
  61. - require:
  62. - file: salt_env_{{ master.system.environment }}_dirs
  63. - pkg: git_packages
  64. {%- endif %}
  65. {%- endfor %}
  66. {%- if master.system.returners is defined %}
  67. salt_master_{{ master.system.environment }}_returners:
  68. git.latest:
  69. - name: {{ master.system.returners.address }}
  70. - target: /srv/salt/env/{{ master.system.environment }}/_returners
  71. - rev: {{ master.system.returners.revision }}
  72. - require:
  73. - file: salt_env_{{ master.system.environment }}_dirs
  74. - pkg: git_packages
  75. {%- endif %}
  76. {%- endif %}
  77. {# Start new #}
  78. {%- for environment_name, environment in master.get('environment', {}).iteritems() %}
  79. {%- if master.base_environment == environment_name %}
  80. salt_env_{{ environment_name }}_pre_dirs:
  81. file.directory:
  82. - names:
  83. - /usr/share/salt-formulas/env/_modules
  84. - /usr/share/salt-formulas/env/_states
  85. - /usr/share/salt-formulas/env/_grains
  86. - /usr/share/salt-formulas/env/_formulas
  87. - makedirs: True
  88. salt_env_{{ environment_name }}_dirs:
  89. file.symlink:
  90. - name: /srv/salt/env/{{ environment_name }}
  91. - target: /usr/share/salt-formulas/env
  92. - require:
  93. - file: salt_env_{{ environment_name }}_pre_dirs
  94. {%- else %}
  95. salt_env_{{ environment_name }}_dirs:
  96. file.directory:
  97. - names:
  98. - /srv/salt/env/{{ environment_name }}/_modules
  99. - /srv/salt/env/{{ environment_name }}/_states
  100. - /srv/salt/env/{{ environment_name }}/_grains
  101. - /srv/salt/env/{{ environment_name }}/_formulas
  102. - makedirs: True
  103. {%- endif %}
  104. {%- for formula_name, formula in environment.get('formula', {}).iteritems() %}
  105. {%- if formula.source == 'pkg' %}
  106. salt_master_{{ environment_name }}_{{ formula.name }}_formula:
  107. pkg.latest:
  108. - name: {{ formula.name }}
  109. {%- elif formula.source == 'git' %}
  110. {%- if master.base_environment == environment_name %}
  111. salt_master_{{ environment_name }}_{{ formula_name }}_formula:
  112. git.latest:
  113. - name: {{ formula.address }}
  114. - target: /usr/share/salt-formulas/env/_formulas/{{ formula_name }}
  115. - rev: {{ formula.revision }}
  116. - require:
  117. - file: salt_env_{{ environment_name }}_dirs
  118. - pkg: git_packages
  119. salt_env_{{ environment_name }}_{{ formula_name }}_link:
  120. file.symlink:
  121. - name: /usr/share/salt-formulas/env/{{ formula_name }}
  122. - target: /usr/share/salt-formulas/env/_formulas/{{ formula_name }}/{{ formula_name }}
  123. - require:
  124. - file: salt_env_{{ environment_name }}_dirs
  125. {%- for grain_name, grain in formula.get('grain', {}).iteritems() %}
  126. salt_master_{{ environment_name }}_{{ grain_name }}_grain:
  127. file.symlink:
  128. - name: /usr/share/salt-formulas/env/_grains/{{ grain_name }}
  129. - target: /usr/share/salt-formulas/env/_formulas/{{ formula_name }}/_grains/{{ grain_name }}
  130. {%- endfor %}
  131. {%- for module_name, module in formula.get('module', {}).iteritems() %}
  132. salt_master_{{ environment_name }}_{{ module_name }}_module:
  133. file.symlink:
  134. - name: /usr/share/salt-formulas/env/_modules/{{ module_name }}
  135. - target: /usr/share/salt-formulas/env/_formulas/{{ formula_name }}/_modules/{{ module_name }}
  136. {%- endfor %}
  137. {%- for state_name, state in formula.get('state', {}).iteritems() %}
  138. salt_master_{{ environment_name }}_{{ state_name }}_state:
  139. file.symlink:
  140. - name: /usr/share/salt-formulas/env/_states/{{ state_name }}
  141. - target: /usr/share/salt-formulas/env/_formulas/{{ formula_name }}/_states/{{ state_name }}
  142. {%- endfor %}
  143. {%- else %}
  144. salt_master_{{ environment_name }}_{{ formula_name }}_formula:
  145. git.latest:
  146. - name: {{ formula.address }}
  147. - target: /srv/salt/env/{{ environment_name }}/_formulas/{{ formula_name }}
  148. - rev: {{ formula.revision }}
  149. - require:
  150. - file: salt_env_{{ environment_name }}_dirs
  151. - pkg: git_packages
  152. salt_env_{{ environment_name }}_{{ formula_name }}_link:
  153. file.symlink:
  154. - name: /srv/salt/env/{{ environment_name }}/{{ formula_name }}
  155. - target: /srv/salt/env/{{ environment_name }}/_formulas/{{ formula_name }}/{{ formula_name }}
  156. - require:
  157. - file: salt_env_{{ environment_name }}_dirs
  158. {%- for grain_name, grain in formula.get('grain', {}).iteritems() %}
  159. salt_master_{{ environment_name }}_{{ grain_name }}_grain:
  160. file.symlink:
  161. - name: /srv/salt/env/{{ environment_name }}/_grains/{{ grain_name }}
  162. - target: /srv/salt/env/{{ environment_name }}/_formulas/{{ formula_name }}/_grains/{{ grain_name }}
  163. {%- endfor %}
  164. {%- for module_name, module in formula.get('module', {}).iteritems() %}
  165. salt_master_{{ environment_name }}_{{ module_name }}_module:
  166. file.symlink:
  167. - name: /srv/salt/env/{{ environment_name }}/_grains/{{ module_name }}
  168. - target: /srv/salt/env/{{ environment_name }}/_formulas/{{ formula_name }}/_grains/{{ module_name }}
  169. {%- endfor %}
  170. {%- for state_name, state in formula.get('state', {}).iteritems() %}
  171. salt_master_{{ environment_name }}_{{ state_name }}_state:
  172. file.symlink:
  173. - name: /srv/salt/env/{{ environment_name }}/_grains/{{ state_name }}
  174. - target: /srv/salt/env/{{ environment_name }}/_formulas/{{ formula_name }}/_grains/{{ state_name }}
  175. {%- endfor %}
  176. {%- endif %}
  177. {%- endif %}
  178. {%- endfor %}
  179. {%- endfor %}
  180. {# end new #}
  181. {%- endif %}