New version of salt-formula from Saltstack
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

78 lines
2.2KB

  1. {%- from "salt/map.jinja" import minion with context %}
  2. {%- if minion.enabled %}
  3. {%- if minion.source.get('engine', 'pkg') == 'pkg' %}
  4. salt_minion_packages:
  5. pkg.latest:
  6. - names: {{ minion.pkgs }}
  7. {%- if minion.source.version is defined %}
  8. - version: {{ minion.source.version }}
  9. {%- endif %}
  10. {%- elif minion.source.get('engine', 'pkg') == 'pip' %}
  11. salt_minion_packages:
  12. pip.installed:
  13. - name: salt{% if minion.source.version is defined %}=={{ minion.source.version }}{% endif %}
  14. {%- endif %}
  15. /etc/salt/minion.d/minion.conf:
  16. file.managed:
  17. - source: salt://salt/files/minion.conf
  18. - user: root
  19. - group: root
  20. - template: jinja
  21. - require:
  22. - {{ minion.install_state }}
  23. {%- if not grains.get('noservices', False) %}
  24. - watch_in:
  25. - service: salt_minion_service
  26. {%- endif %}
  27. {%- for service_name, service in pillar.items() %}
  28. {%- set support_fragment_file = service_name+'/meta/salt.yml' %}
  29. {%- macro load_support_file() %}{% include support_fragment_file ignore missing %}{% endmacro %}
  30. {%- set support_yaml = load_support_file()|load_yaml %}
  31. {%- if support_yaml and support_yaml.get('minion', {}) %}
  32. {%- for name, conf in support_yaml.get('minion', {}).iteritems() %}
  33. salt_minion_config_{{ service_name }}_{{ name }}:
  34. file.managed:
  35. - name: /etc/salt/minion.d/_{{ name }}.conf
  36. - contents: |
  37. {{ conf|yaml(False)|indent(8) }}
  38. - require:
  39. - {{ minion.install_state }}
  40. salt_minion_config_{{ service_name }}_{{ name }}_validity_check:
  41. cmd.wait:
  42. - name: python -c "import yaml; stream = file('/etc/salt/minion.d/_{{ name }}.conf', 'r'); yaml.load(stream); stream.close()"
  43. - watch:
  44. - file: salt_minion_config_{{ service_name }}_{{ name }}
  45. {%- if not grains.get('noservices', False) %}
  46. - watch_in:
  47. - service: salt_minion_service
  48. {%- endif %}
  49. {%- endfor %}
  50. {%- endif %}
  51. {%- endfor %}
  52. {%- if not grains.get('noservices', False) %}
  53. salt_minion_service:
  54. service.running:
  55. - name: {{ minion.service }}
  56. - enable: true
  57. {%- endif %}
  58. salt_minion_sync_all:
  59. module.run:
  60. - name: 'saltutil.sync_all'
  61. {%- if not grains.get('noservices', False) %}
  62. - watch:
  63. - service: salt_minion_service
  64. {%- endif %}
  65. {%- endif %}