New version of salt-formula from Saltstack
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.

minion.sls 1.3KB

9 years ago
9 years ago
9 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {%- from "salt/map.jinja" import master with context %}
  2. {%- if master.enabled %}
  3. include:
  4. - salt.master.service
  5. /etc/salt/minion.d/_orchestration.conf:
  6. file.managed:
  7. - source: salt://salt/files/_orchestration.conf
  8. - user: root
  9. - group: root
  10. - mode: 600
  11. - template: jinja
  12. - makedirs: true
  13. - require:
  14. - {{ master.install_state }}
  15. {%- if master.minion is defined %}
  16. /srv/salt/minion_keys:
  17. file.directory:
  18. - makedirs: true
  19. - require:
  20. - {{ master.install_state }}
  21. {%- for name, environment in master.environment.iteritems() %}
  22. /srv/salt/env/{{ name }}/minion_keys:
  23. file.symlink:
  24. - target: /srv/salt/minion_keys
  25. - require:
  26. - file: /srv/salt/minion_keys
  27. {%- endfor %}
  28. {%- for minion in master.minion %}
  29. generate_key_{{ minion.name }}:
  30. cmd.run:
  31. - name: salt-key --gen-keys={{ minion.name }} --gen-keys-dir=/srv/salt/minion_keys
  32. - unless: "test -e /srv/salt/minion_keys/{{ minion.name}}.pem"
  33. - require:
  34. - file: /srv/salt/minion_keys
  35. copy_generated_key_{{ minion.name }}:
  36. cmd.run:
  37. - name: cp /srv/salt/minion_keys/{{ minion.name }}.pub /etc/salt/pki/master/minions/{{ minion.name }}
  38. - unless: "test -e /etc/salt/pki/master/minions/{{ minion.name }}"
  39. - require:
  40. - cmd: generate_key_{{ minion.name }}
  41. {%- endfor %}
  42. {%- endif %}
  43. {%- endif %}