Saltstack Official OpenSSH 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.

33 lines
1.0KB

  1. include:
  2. - openssh
  3. {% from "openssh/map.jinja" import openssh, sshd_config with context -%}
  4. {%- set authorized_keys_file = sshd_config.get("AuthorizedKeysFile", None) %}
  5. {%- for store, config in openssh.get("auth_map", {}).items() %}
  6. {%- set store_base = config["source"] %}
  7. # SSH store openssh:auth_map:{{ store }}
  8. {%- for user, keys in config.get("users", {}).items() %}
  9. {%- for key, key_cfg in keys.items() %}
  10. "ssh_auth--{{ store }}--{{ user }}--{{ key }}":
  11. {%- set present = key_cfg.get("present", True) %}
  12. {%- set options = key_cfg.get("options", []) %}
  13. {%- if present %}
  14. ssh_auth.present:
  15. - require:
  16. - service: {{ openssh.service }}
  17. {%- else %}
  18. ssh_auth.absent:
  19. {%- endif %}
  20. - user: {{ user }}
  21. - source: {{ store_base }}/{{ key }}.pub
  22. {%- if authorized_keys_file %}
  23. - config: "{{ authorized_keys_file }}"
  24. {%- endif %}
  25. {%- if options %}
  26. - options: "{{ options }}"
  27. {%- endif %}
  28. {%- endfor %}
  29. {%- endfor %}
  30. {%- endfor %}