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.

46 lines
1.0KB

  1. {%- from "salt/map.jinja" import master with context %}
  2. {%- if master.enabled %}
  3. include:
  4. - salt.master.service
  5. {%- if master.minion is defined %}
  6. /srv/salt/minion_keys:
  7. file.directory:
  8. - makedirs: true
  9. - require:
  10. - {{ master.install_state }}
  11. {%- for name, environment in master.environment.iteritems() %}
  12. /srv/salt/env/{{ name }}/minion_keys:
  13. file.symlink:
  14. - target: /srv/salt/minion_keys
  15. - require:
  16. - file: /srv/salt/minion_keys
  17. {%- endfor %}
  18. {%- for minion in master.minion %}
  19. generate_key_{{ minion.name }}:
  20. cmd.run:
  21. - name: salt-key --gen-keys={{ minion.name }} --gen-keys-dir=/srv/salt/minion_keys
  22. - unless: "test -e /srv/salt/minion_keys/{{ minion.name}}.pem"
  23. - require:
  24. - file: /srv/salt/minion_keys
  25. copy_generated_key_{{ minion.name }}:
  26. cmd.run:
  27. - name: cp /srv/salt/minion_keys/{{ minion.name }}.pub /etc/salt/pki/master/minions/{{ minion.name }}
  28. - unless: "test -e /etc/salt/pki/master/minions/{{ minion.name }}"
  29. - require:
  30. - cmd: generate_key_{{ minion.name }}
  31. {%- endfor %}
  32. {%- endif %}
  33. {%- endif %}