security.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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: Reconfigure rkhunter package
  64. debconf: name="{{item.name}}" question="{{item.question}}" value="{{item.value}}" vtype="{{item.vtype}}"
  65. with_items:
  66. - { name: 'rkhunter', question: 'rkhunter/apt_autogen', value: 'true', vtype: 'boolean' }
  67. - { name: 'rkhunter', question: 'rkhunter/cron_daily_run', value: 'true', vtype: 'boolean' }
  68. - { name: 'rkhunter', question: 'rkhunter/cron_db_update', value: 'true', vtype: 'boolean' }
  69. notify:
  70. - Reconfigure rkhunter
  71. when: with_rkhunter
  72. - name: Update rkhunter configuration
  73. template: src=rkhunter/{{ ansible_lsb.codename }}.conf.j2 dest=/etc/rkhunter.conf owner=root group=root mode=0644
  74. when: with_rkhunter
  75. - name: Update chkrootkit configuration
  76. template: src=chkrootkit/chkrootkit.conf.j2 dest=/etc/chkrootkit.conf owner=root group=root mode=0644
  77. when: with_chkrootkit
  78. - name: Update fstab to hide pids from /proc
  79. 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
  80. notify:
  81. - Remount /proc
  82. when: with_hideproc and hideproc_gid == ''
  83. - name: Update fstab to hide pids from /proc with group id (gid)
  84. 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
  85. notify:
  86. - Remount /proc
  87. when: with_hideproc and hideproc_gid != ''
  88. - name: Create Diffie-Helman parameters
  89. command: openssl dhparam -2 -out /etc/ssl/private/dh{{ item }}.pem {{ item }} creates=/etc/ssl/private/dh{{ item }}.pem
  90. with_items:
  91. - 2048