authorized_keys.tmpl 712 B

123456789101112131415
  1. {%- set ssh_config = salt['pillar.get']('ssh') %}
  2. {%- for entry_name, entry in ssh_config.get('keys',{}).items() if entry.get('pillar', False) %}
  3. {%- set entry_split = entry_name.split('@') %}
  4. {%- if entry_split|length() == 2 %}
  5. {%- set user = entry_split[0] %}
  6. {%- set host = entry_split[1] %}
  7. {%- else %}
  8. {%- set user = 'root' %}
  9. {%- set host = entry_split[0] %}
  10. {%- endif %}
  11. {%- do entry.update({ 'pubkeys': [salt['pillar.get']('nodes:' + host + ':ssh:' + user + ':pubkey')]}) %}
  12. {%- endfor %}
  13. {%- set node_config = salt['pillar.get']('node') -%}
  14. {%- set auth_keys = salt['ffho_auth.get_ssh_authkeys'](ssh_config, node_config, grains['id'], username) -%}
  15. {{ "\n".join (auth_keys) }}