security.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. - systemd
  53. - zabbix-agentd
  54. when: with_logcheck
  55. - name: Update logcheck cron job
  56. template: src=cron/logcheck.j2 dest=/etc/cron.d/logcheck owner=root group=root mode=0644
  57. when: with_logcheck
  58. - name: Install rkhunter related packages
  59. apt: pkg={{ item }} state=installed update_cache=yes
  60. with_items:
  61. - lsof
  62. - unhide
  63. - rkhunter
  64. when: with_rkhunter
  65. - name: Reconfigure rkhunter package
  66. debconf: name="{{item.name}}" question="{{item.question}}" value="{{item.value}}" vtype="{{item.vtype}}"
  67. with_items:
  68. - { name: 'rkhunter', question: 'rkhunter/apt_autogen', value: 'true', vtype: 'boolean' }
  69. - { name: 'rkhunter', question: 'rkhunter/cron_daily_run', value: 'true', vtype: 'boolean' }
  70. - { name: 'rkhunter', question: 'rkhunter/cron_db_update', value: 'true', vtype: 'boolean' }
  71. notify:
  72. - Reconfigure rkhunter
  73. when: with_rkhunter
  74. - name: Update rkhunter configuration
  75. template: src=rkhunter/{{ ansible_lsb.codename }}.conf.j2 dest=/etc/rkhunter.conf owner=root group=root mode=0644
  76. when: with_rkhunter
  77. - name: Update chkrootkit configuration
  78. template: src=chkrootkit/chkrootkit.conf.j2 dest=/etc/chkrootkit.conf owner=root group=root mode=0644
  79. when: with_chkrootkit
  80. - name: Update fstab to hide pids from /proc
  81. 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
  82. notify:
  83. - Remount /proc
  84. when: with_hideproc and hideproc_gid == ''
  85. - name: Update fstab to hide pids from /proc with group id (gid)
  86. 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
  87. notify:
  88. - Remount /proc
  89. when: with_hideproc and hideproc_gid != ''
  90. - name: 'Create Diffie-Helman parameters'
  91. command: 'openssl dhparam -2 -out /etc/ssl/private/dh{{ item }}.pem {{ item }}'
  92. args:
  93. creates: '/etc/ssl/private/dh{{ item }}.pem'
  94. with_items:
  95. - 2048