ssh.yml 789 B

123456789101112131415161718192021222324252627282930313233343536
  1. - name: "Install ssh packages"
  2. apt:
  3. pkg: '{{ item }}'
  4. state: 'installed'
  5. with_items:
  6. - 'openssh-server'
  7. - 'openssh-client'
  8. when: with_ssh
  9. - name: 'Install sshd configuration (Debian <= 8)'
  10. template:
  11. src: 'ssh/sshd_config.legacy.j2'
  12. dest: '/etc/ssh/sshd_config'
  13. owner: 'root'
  14. group: 'root'
  15. mode: 0644
  16. notify:
  17. - Restart ssh
  18. when: with_ssh and ansible_lsb.major_release|int <= 8
  19. - name: 'Install sshd configuration (Debian >= 9)'
  20. template:
  21. src: 'ssh/sshd_config.j2'
  22. dest: '/etc/ssh/sshd_config'
  23. owner: 'root'
  24. group: 'root'
  25. mode: 0644
  26. notify:
  27. - Restart ssh
  28. when: with_ssh and ansible_lsb.major_release|int >= 9
  29. - name: 'Ensure ssh is running'
  30. service:
  31. name: 'ssh'
  32. state: 'started'
  33. when: with_ssh