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:
|
2022-11-20 20:03:01 -06:00
|
|
|
name:
|
2022-05-02 15:00:29 -05:00
|
|
|
- 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
|
|
|
|
|
2023-02-20 16:50:10 -06:00
|
|
|
- name: suricata config files
|
|
|
|
become: yes
|
|
|
|
copy:
|
|
|
|
src: suricata/
|
|
|
|
dest: /etc/suricata/
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0600
|
|
|
|
|
|
|
|
- name: suricata config template
|
|
|
|
become: yes
|
|
|
|
template:
|
|
|
|
src: suricata.yaml.j2
|
|
|
|
dest: /etc/suricata/suricata.yaml
|
|
|
|
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
|
2022-11-20 20:03:01 -06:00
|
|
|
loop:
|
2022-05-03 16:57:52 -05:00
|
|
|
- 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
|
2022-11-20 20:03:01 -06:00
|
|
|
loop:
|
2022-05-03 16:57:52 -05:00
|
|
|
- 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:
|
2022-11-20 20:03:01 -06:00
|
|
|
name: oinkmaster.service
|
2022-05-03 16:57:52 -05:00
|
|
|
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
|
2022-11-20 20:03:01 -06:00
|
|
|
loop:
|
2022-05-02 15:00:29 -05:00
|
|
|
- suricata.service
|
|
|
|
- sshguard.service
|
2022-05-03 16:57:52 -05:00
|
|
|
- oinkmaster.timer
|
|
|
|
- rkhunter.timer
|
2022-11-20 20:03:01 -06:00
|
|
|
service:
|
2022-05-02 15:00:29 -05:00
|
|
|
name: "{{ item }}"
|
|
|
|
state: restarted
|
|
|
|
enabled: yes
|