Saltstack Official OpenSSH Formula
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. {% from "openssh/map.jinja" import openssh with context %}
  2. include:
  3. - openssh
  4. {% if salt['pillar.get']('sshd_config', False) %}
  5. sshd_config:
  6. file.managed:
  7. - name: {{ openssh.sshd_config }}
  8. - source: {{ openssh.sshd_config_src }}
  9. - template: jinja
  10. - user: {{ openssh.sshd_config_user }}
  11. - group: {{ openssh.sshd_config_group }}
  12. - mode: {{ openssh.sshd_config_mode }}
  13. - watch_in:
  14. - service: {{ openssh.service }}
  15. {% endif %}
  16. {% if salt['pillar.get']('ssh_config', False) %}
  17. ssh_config:
  18. file.managed:
  19. - name: {{ openssh.ssh_config }}
  20. - source: {{ openssh.ssh_config_src }}
  21. - template: jinja
  22. - user: {{ openssh.ssh_config_user }}
  23. - group: {{ openssh.ssh_config_group }}
  24. - mode: {{ openssh.ssh_config_mode }}
  25. {% endif %}
  26. {%- for keyType in ['ecdsa', 'dsa', 'rsa', 'ed25519'] %}
  27. {%- set keyFile = "/etc/ssh/ssh_host_" ~ keyType ~ "_key" %}
  28. {%- set keySize = salt['pillar.get']('openssh:generate_' ~ keyType ~ '_size', False) %}
  29. {%- if salt['pillar.get']('openssh:generate_' ~ keyType ~ '_keys', False) %}
  30. {%- if keySize and salt['pillar.get']('openssh:enforce_' ~ keyType ~ '_size', False) %}
  31. ssh_remove_short_{{ keyType }}_key:
  32. cmd.run:
  33. - name: "rm -f {{ keyFile }} {{ keyFile }}.pub"
  34. - onlyif: "test -f {{ keyFile }}.pub && test `ssh-keygen -l -f {{ keyFile }}.pub 2>/dev/null | awk '{print $1}'` -lt {{ keySize }}"
  35. - require_in:
  36. - cmd: ssh_generate_host_{{ keyType }}_key
  37. {%- endif %}
  38. ssh_generate_host_{{ keyType }}_key:
  39. cmd.run:
  40. {%- if keySize %}
  41. - name: ssh-keygen -t {{ keyType }} -b {{ keySize }} -N '' -f {{ keyFile }}
  42. {%- else %}
  43. - name: ssh-keygen -t {{ keyType }} -N '' -f {{ keyFile }}
  44. {%- endif %}
  45. - creates: /etc/ssh/ssh_host_{{ keyType }}_key
  46. - user: root
  47. - watch_in:
  48. - service: {{ openssh.service }}
  49. {%- elif salt['pillar.get']('openssh:absent_' ~ keyType ~ '_keys', False) %}
  50. ssh_host_{{ keyType }}_key:
  51. file.absent:
  52. - name: {{ keyFile }}
  53. - watch_in:
  54. - service: {{ openssh.service }}
  55. ssh_host_{{ keyType }}_key.pub:
  56. file.absent:
  57. - name: {{ keyFile }}.pub
  58. - watch_in:
  59. - service: {{ openssh.service }}
  60. {%- elif salt['pillar.get']('openssh:provide_' ~ keyType ~ '_keys', False) %}
  61. ssh_host_{{ keyType }}_key:
  62. file.managed:
  63. - name: {{ keyFile }}
  64. - contents_pillar: 'openssh:{{ keyType }}:private_key'
  65. - user: root
  66. - mode: 600
  67. - watch_in:
  68. - service: {{ openssh.service }}
  69. ssh_host_{{ keyType }}_key.pub:
  70. file.managed:
  71. - name: {{ keyFile }}.pub
  72. - contents_pillar: 'openssh:{{ keyType }}:public_key'
  73. - user: root
  74. - mode: 600
  75. - watch_in:
  76. - service: {{ openssh.service }}
  77. {%- endif %}
  78. {%- endfor %}