forked from elmuz/catafalco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add my own crowdsec role, test with a new LAN and fix a few bugs
- Loading branch information
Showing
12 changed files
with
123 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- name: Restart netfilter-persistent | ||
service: | ||
name: netfilter-persistent | ||
state: restarted | ||
|
||
- name: Restart crowdsec | ||
service: | ||
name: crowdsec | ||
state: restarted | ||
|
||
|
||
- name: Restart prometheus | ||
service: | ||
name: prometheus | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
- name: Add Crowdsec GPG apt Key | ||
apt_key: | ||
url: https://packagecloud.io/crowdsec/crowdsec/gpgkey | ||
state: present | ||
|
||
- name: Add Crowdsec Repository | ||
apt_repository: | ||
repo: deb https://packagecloud.io/crowdsec/crowdsec/ubuntu bionic stable | ||
state: present | ||
|
||
- name: Update apt and install Crowdsec and Prometheus | ||
apt: | ||
update_cache: yes | ||
name: | ||
- crowdsec | ||
- crowdsec-firewall-bouncer-iptables | ||
- prometheus | ||
state: present | ||
|
||
- name: cscli hub update | ||
command: | ||
cmd: cscli hub update | ||
changed_when: false | ||
|
||
- name: Install the necessary collections | ||
command: | ||
cmd: "sudo cscli collections install crowdsecurity/{{ item }}" | ||
with_items: | ||
- nginx | ||
- sshd | ||
- linux | ||
- iptables | ||
register: collections_install_result | ||
changed_when: "'overwrite' not in collections_install_result.stderr" | ||
|
||
- name: Enable the Prometheus endpoint | ||
lineinfile: | ||
path: "/etc/crowdsec/config.yaml" | ||
line: " enabled: true" | ||
search_string: "enabled: false" | ||
insertafter: "^prometeus:.*$" | ||
notify: | ||
- Restart prometheus | ||
- Restart crowdsec | ||
|
||
- name: Increase ban time | ||
replace: | ||
path: "/etc/crowdsec/profiles.yaml" | ||
regexp: 'duration: [0-9]h' | ||
replace: 'duration: 999h' | ||
notify: | ||
- Restart crowdsec | ||
|
||
- name: Start and enable Crowdsec services | ||
service: | ||
name: "{{ item }}" | ||
state: started | ||
enabled: true | ||
with_items: | ||
- crowdsec | ||
- crowdsec-firewall-bouncer | ||
- prometheus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: Install netfilters-persistent | ||
package: | ||
name: netfilter-persistent | ||
state: present | ||
|
||
- name: Log port scanning attempts (iptables) | ||
iptables: | ||
chain: INPUT | ||
match: conntrack | ||
ctstate: NEW | ||
comment: "Log new connections" | ||
jump: LOG | ||
|
||
- name: Persist the port scanning rule (iptables) | ||
community.general.iptables_state: | ||
ip_version: ipv4 | ||
table: filter | ||
state: saved | ||
path: /etc/iptables/rules.v4 | ||
notify: | ||
- Restart netfilter-persistent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- include_tasks: iptables.yml | ||
- include_tasks: crowdsec.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters