ssh.yml 886 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. - name: "Install ssh packages"
  2. apt:
  3. pkg:
  4. - 'openssh-server'
  5. - 'openssh-client'
  6. state: 'present'
  7. when: with_ssh|bool
  8. tags:
  9. - 'ssh'
  10. - name: 'Install sshd configuration (Debian <= 8)'
  11. template:
  12. src: 'ssh/sshd_config.legacy.j2'
  13. dest: '/etc/ssh/sshd_config'
  14. owner: 'root'
  15. group: 'root'
  16. mode: 0644
  17. notify:
  18. - Restart ssh
  19. when: with_ssh|bool and ansible_lsb.major_release|int <= 8
  20. tags:
  21. - 'ssh'
  22. - name: 'Install sshd configuration (Debian >= 9)'
  23. template:
  24. src: 'ssh/sshd_config.j2'
  25. dest: '/etc/ssh/sshd_config'
  26. owner: 'root'
  27. group: 'root'
  28. mode: 0644
  29. notify:
  30. - Restart ssh
  31. when: with_ssh|bool and ansible_lsb.major_release|int >= 9
  32. tags:
  33. - 'ssh'
  34. - name: 'Ensure ssh is running'
  35. service:
  36. name: 'ssh'
  37. state: 'started'
  38. when: with_ssh|bool
  39. tags:
  40. - 'ssh'
  41. # vim: ft=yaml.ansible