security.yml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. - name: Install auto upgrades package
  2. apt: pkg=unattended-upgrades state=installed update_cache=yes
  3. when: with_auto_upgrade
  4. - name: Reconfigure unattended-upgrades package
  5. debconf: name="unattended-upgrades" question="unattended-upgrades/enable_auto_updates" value="true" vtype="boolean"
  6. notify:
  7. - Reconfigure unattended-upgrades
  8. when: with_auto_upgrade
  9. - name: Update unattended-upgrades configuration
  10. template: src={{ item }} dest=/etc/apt/apt.conf.d/90unattended-upgrades-local owner=root group=root mode=0644
  11. first_available_file:
  12. - apt/auto-upgrades.{{ ansible_lsb.codename }}.j2
  13. - apt/auto-upgrades.j2
  14. when: with_auto_upgrade
  15. - name: Install logcheck packages
  16. apt: pkg={{ item }} state=installed update_cache=yes
  17. with_items:
  18. - logcheck
  19. - logcheck-database
  20. when: with_logcheck
  21. - name: Install local configuration files for logcheck
  22. copy: src=logcheck/{{ item }}_local dest=/etc/logcheck/ignore.d.server/{{ item }}_local owner=root group=root mode=0644
  23. with_items:
  24. - amavisd-new
  25. - ansible
  26. - bind
  27. - dhclient
  28. - dovecot
  29. - dropbear
  30. - git-daemon
  31. - ipmi
  32. - irqbalance
  33. - kernel
  34. - libpam-modules
  35. - mon
  36. - noip2
  37. - ntp
  38. - openvpn
  39. - php
  40. - postfix
  41. - pure-ftpd
  42. - pve-cluster
  43. - redir
  44. - rpc.mountd
  45. - rrdcached
  46. - rsyslog
  47. - smartd
  48. - spamd
  49. - sshd
  50. - svn
  51. - sympa
  52. when: with_logcheck
  53. - name: Update logcheck cron job
  54. template: src=cron/logcheck.j2 dest=/etc/cron.d/logcheck owner=root group=root mode=0644
  55. when: with_logcheck
  56. - name: Install rkhunter related packages
  57. apt: pkg={{ item }} state=installed update_cache=yes
  58. with_items:
  59. - lsof
  60. - unhide
  61. - rkhunter
  62. when: with_rkhunter
  63. - name: Update rkhunter default/init parameters
  64. template: src=rkhunter/default.j2 dest=/etc/default/rkhunter owner=root group=root mode=0644
  65. when: with_rkhunter
  66. - name: Update rkhunter configuration
  67. template: src=rkhunter/{{ ansible_lsb.codename }}.conf.j2 dest=/etc/rkhunter.conf owner=root group=root mode=0644
  68. when: with_rkhunter
  69. - name: Update chkrootkit configuration
  70. template: src=chkrootkit/chkrootkit.conf.j2 dest=/etc/chkrootkit.conf owner=root group=root mode=0644
  71. when: with_chkrootkit
  72. - name: Update fstab to hide pids from /proc
  73. lineinfile: dest=/etc/fstab regexp='(^proc\s+/proc\s+proc\s+)(\S+)(\s+[0-9]\s+[0-9])\s*$' line='\1defaults,hidepid=2\3' backrefs=yes
  74. notify:
  75. - Remount /proc
  76. when: with_hideproc and hideproc_gid == ''
  77. - name: Update fstab to hide pids from /proc with group id (gid)
  78. lineinfile: dest=/etc/fstab regexp='(^proc\s+/proc\s+proc\s+)(\S+)(\s+[0-9]\s+[0-9])\s*$' line='\1defaults,hidepid=2,gid={{hideproc_gid}}\3' backrefs=yes
  79. notify:
  80. - Remount /proc
  81. when: with_hideproc and hideproc_gid != ''
  82. - name: Create Diffie-Helman parameters
  83. command: openssl dhparam -2 -out /etc/ssl/private/dh{{ item }}.pem {{ item }} creates=/etc/ssl/private/dh{{ item }}.pem
  84. with_items:
  85. - 2048