2022-05-02 15:00:29 -05:00
|
|
|
---
|
|
|
|
|
2022-05-03 16:57:52 -05:00
|
|
|
- name: IDS packages
|
2022-05-02 15:00:29 -05:00
|
|
|
become: yes
|
2022-05-03 16:57:52 -05:00
|
|
|
register: package_install
|
2022-05-02 15:00:29 -05:00
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- sshguard
|
|
|
|
- suricata
|
|
|
|
- oinkmaster
|
2022-05-03 16:57:52 -05:00
|
|
|
- rkhunter
|
2022-05-02 15:00:29 -05:00
|
|
|
state: present
|
|
|
|
|
2022-05-03 16:57:52 -05:00
|
|
|
# Network IPS
|
2022-05-02 15:00:29 -05:00
|
|
|
- name: sshguard config
|
|
|
|
become: yes
|
|
|
|
copy:
|
|
|
|
src: sshguard.conf
|
|
|
|
dest: /etc/sshguard.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0600
|
|
|
|
|
|
|
|
- name: sshguard allowlist
|
|
|
|
become: yes
|
|
|
|
copy:
|
|
|
|
dest: /etc/sshguard.allowlist
|
|
|
|
content: |
|
|
|
|
"{{ router }}/{{ netmask }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0600
|
|
|
|
|
2022-05-03 16:57:52 -05:00
|
|
|
# Host IDS
|
|
|
|
- name: Copy rkhunter service
|
|
|
|
register: rkhunter_conf
|
|
|
|
become: yes
|
|
|
|
copy:
|
|
|
|
src: rkhunter/rkhunter.conf
|
|
|
|
dest: "/etc/rkhunter.conf"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: Copy rkhunter service
|
|
|
|
register: rkhunter_service
|
|
|
|
become: yes
|
|
|
|
loop:
|
|
|
|
- rkhunter.service
|
|
|
|
- rkhunter.timer
|
|
|
|
copy:
|
|
|
|
src: "rkhunter/{{ item }}"
|
|
|
|
dest: "/usr/lib/systemd/system/{{ item }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
# Network IDS
|
|
|
|
- name: Copy oinkmaster conf
|
|
|
|
register: oinkmaster_conf
|
|
|
|
become: yes
|
|
|
|
copy:
|
|
|
|
src: "oinkmaster/oinkmaster.conf"
|
|
|
|
dest: "/usr/lib/systemd/system/oinkmaster.conf"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: Copy oinkmaster service
|
|
|
|
register: oinkmaster_service
|
|
|
|
become: yes
|
|
|
|
loop:
|
|
|
|
- oinkmaster.service
|
|
|
|
- oinkmaster.timer
|
|
|
|
copy:
|
|
|
|
src: "oinkmaster/{{ item }}"
|
|
|
|
dest: "/usr/lib/systemd/system/{{ item }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
become: yes
|
|
|
|
when: oinkmaster_service.changed or rkhunter_service.changed
|
|
|
|
|
|
|
|
- name: Update oinkmaster DB
|
|
|
|
become: yes
|
|
|
|
when: package_install.changed or oinkmaster_conf.changed
|
|
|
|
service:
|
|
|
|
name: oinkmaster.service
|
|
|
|
state: started
|
|
|
|
|
|
|
|
- name: Update rkhunter DB
|
|
|
|
become: yes
|
|
|
|
when: package_install.changed or rkhunter_conf.changed
|
|
|
|
command: "/bin/bash -c 'export PATH=/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; rkhunter -C && rkhunter --propupd'"
|
2022-05-02 15:00:29 -05:00
|
|
|
|
|
|
|
- name: IDS services
|
|
|
|
become: yes
|
|
|
|
loop:
|
|
|
|
- suricata.service
|
|
|
|
- sshguard.service
|
2022-05-03 16:57:52 -05:00
|
|
|
- oinkmaster.timer
|
|
|
|
- rkhunter.timer
|
2022-05-02 15:00:29 -05:00
|
|
|
service:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: restarted
|
|
|
|
enabled: yes
|