main.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ---
  2. - name: Fix timezone
  3. file:
  4. src: /usr/share/zoneinfo/{{ timezone }}
  5. dest: /etc/zoneinfo
  6. state: link
  7. - name: Disable cockpit
  8. systemd:
  9. name: cockpit.socket
  10. state: stopped
  11. enabled: no
  12. when:
  13. - ansible_os_family == 'Fedora'
  14. - name: Close cockpit port
  15. firewalld:
  16. zone: FedoraServer
  17. service: cockpit
  18. state: disabled
  19. permanent: yes
  20. immediate: yes
  21. when:
  22. - ansible_os_family == 'Fedora'
  23. - name: Remove cockpit motd banner
  24. file:
  25. path: /etc/motd.d/cockpit
  26. state: absent
  27. when:
  28. - ansible_os_family == 'Fedora'
  29. - name: Check for systemd-oomd conf file
  30. ansible.builtin.stat:
  31. path: /etc/systemd/oomd.conf
  32. register: oomd_conf
  33. - name: Create copy of oomd.conf
  34. ansible.builtin.copy:
  35. src: /usr/lib/systemd/oomd.conf
  36. dest: /etc/systemd/oomd.conf
  37. remote_src: yes
  38. when:
  39. - oomd_conf.stat.exists == False
  40. - name: Loosen up systemd-oomd defaults
  41. lineinfile:
  42. path: /etc/systemd/oomd.conf
  43. regexp: '^DefaultMemoryPressureLimit='
  44. insertafter: '^#DefaultMemoryPressureLimit='
  45. line: DefaultMemoryPressureLimit=80%
  46. - name: Install fail2ban
  47. package:
  48. name: fail2ban
  49. state: present
  50. - name: Configure fail2ban
  51. template:
  52. src: ssh.local.j2
  53. dest: /etc/fail2ban/jail.d/ssh.local
  54. owner: root
  55. group: root
  56. mode: '0644'
  57. notify: Restart fail2ban
  58. - name: Start/enable fail2ban
  59. systemd:
  60. name: fail2ban
  61. state: started
  62. enabled: yes