security.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. - name: 'Install auto upgrades package'
  2. apt:
  3. pkg: 'unattended-upgrades'
  4. state: 'installed'
  5. when: with_auto_upgrade
  6. - name: 'Reconfigure unattended-upgrades package'
  7. debconf:
  8. name: 'unattended-upgrades'
  9. question: 'unattended-upgrades/enable_auto_updates'
  10. value: 'true'
  11. vtype: 'boolean'
  12. notify:
  13. - 'Reconfigure unattended-upgrades'
  14. when: with_auto_upgrade
  15. - name: 'Update unattended-upgrades configuration'
  16. template:
  17. src: '{{ item }}'
  18. dest: '/etc/apt/apt.conf.d/90unattended-upgrades-local'
  19. owner: 'root'
  20. group: 'root'
  21. mode: '0644'
  22. with_first_found:
  23. - 'apt/auto-upgrades.{{ ansible_lsb.codename }}.j2'
  24. - 'apt/auto-upgrades.j2'
  25. when: with_auto_upgrade
  26. - name: 'Install logcheck packages'
  27. apt:
  28. pkg: '{{ item }}'
  29. state: 'installed'
  30. with_items:
  31. - 'logcheck'
  32. - 'logcheck-database'
  33. when: with_logcheck
  34. - name: 'Install local configuration files for logcheck'
  35. copy:
  36. src: 'logcheck/{{ item }}_local'
  37. dest: '/etc/logcheck/ignore.d.server/{{ item }}_local'
  38. owner: 'root'
  39. group: 'logcheck'
  40. mode: '0644'
  41. with_items:
  42. - 'amavisd-new'
  43. - 'ansible'
  44. - 'apache2'
  45. - 'bind'
  46. - 'dhclient'
  47. - 'dnsmasq'
  48. - 'dovecot'
  49. - 'dropbear'
  50. - 'ferm'
  51. - 'gammu'
  52. - 'git-daemon'
  53. - 'gogs'
  54. - 'influxd'
  55. - 'ipmi'
  56. - 'irqbalance'
  57. - 'kernel'
  58. - 'libpam-modules'
  59. - 'mon'
  60. - 'noip2'
  61. - 'ntp'
  62. - 'openvpn'
  63. - 'php'
  64. - 'postfix'
  65. - 'pure-ftpd'
  66. - 'pve-cluster'
  67. - 'redir'
  68. - 'rpc-mountd'
  69. - 'rrdcached'
  70. - 'rsyslog'
  71. - 'smartd'
  72. - 'spamd'
  73. - 'sshd'
  74. - 'svn'
  75. - 'sympa'
  76. - 'systemd'
  77. - 'zabbix-agentd'
  78. when: with_logcheck
  79. tags:
  80. - 'logcheck'
  81. - name: 'Update logcheck cron job'
  82. template:
  83. src: 'cron/logcheck.j2'
  84. dest: '/etc/cron.d/logcheck'
  85. owner: 'root'
  86. group: 'root'
  87. mode: '0644'
  88. when: with_logcheck
  89. - name: 'Install rkhunter related packages'
  90. apt:
  91. pkg: '{{ item }}'
  92. state: 'installed'
  93. with_items:
  94. - 'lsof'
  95. - 'unhide'
  96. - 'rkhunter'
  97. when: with_rkhunter
  98. - name: 'Reconfigure rkhunter package'
  99. debconf:
  100. name: '{{item.name}}'
  101. question: '{{item.question}}'
  102. value: '{{item.value}}'
  103. vtype: '{{item.vtype}}'
  104. with_items:
  105. - { name: 'rkhunter', question: 'rkhunter/apt_autogen', value: 'true', vtype: 'boolean' }
  106. - { name: 'rkhunter', question: 'rkhunter/cron_daily_run', value: 'true', vtype: 'boolean' }
  107. - { name: 'rkhunter', question: 'rkhunter/cron_db_update', value: 'true', vtype: 'boolean' }
  108. notify:
  109. - 'Reconfigure rkhunter'
  110. when: with_rkhunter
  111. - name: Update rkhunter configuration
  112. template: src=rkhunter/{{ ansible_lsb.codename }}.conf.j2 dest=/etc/rkhunter.conf owner=root group=root mode=0644
  113. when: with_rkhunter
  114. - name: Update chkrootkit configuration
  115. template: src=chkrootkit/chkrootkit.conf.j2 dest=/etc/chkrootkit.conf owner=root group=root mode=0644
  116. when: with_chkrootkit
  117. - name: Update fstab to hide pids from /proc
  118. 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
  119. notify:
  120. - Remount /proc
  121. when: with_hideproc and hideproc_gid == ''
  122. - name: Update fstab to hide pids from /proc with group id (gid)
  123. 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
  124. notify:
  125. - Remount /proc
  126. when: with_hideproc and hideproc_gid != ''
  127. - name: 'Create Diffie-Helman parameters'
  128. command: 'openssl dhparam -2 -out /etc/ssl/private/dh{{ item }}.pem {{ item }}'
  129. args:
  130. creates: '/etc/ssl/private/dh{{ item }}.pem'
  131. with_items:
  132. - '2048'