Added common ansible role
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
sshport: 22
|
||||||
|
openports_list:
|
||||||
|
- 22
|
||||||
|
#blacklist_ip_list:
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- name: update the package list
|
||||||
|
apt: update_cache=yes
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
- name: ensure apticron packages are installed
|
||||||
|
apt:
|
||||||
|
pkg: "{{ packages }}"
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
cache_valid_time: 600
|
||||||
|
vars:
|
||||||
|
packages:
|
||||||
|
- apticron
|
||||||
|
|
||||||
|
- name: configure apticron
|
||||||
|
template:
|
||||||
|
src: etc/apticron/apticron.conf.j2
|
||||||
|
dest: /etc/apticron/apticron.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: set up check disk space cron script
|
||||||
|
template:
|
||||||
|
src: etc/cron.hourly/check-disk-space.sh.j2
|
||||||
|
dest: /etc/cron.hourly/check-disk-space.sh
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0750
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
- name: install fail2ban
|
||||||
|
apt:
|
||||||
|
name: fail2ban
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
- name: enable fail2ban
|
||||||
|
service:
|
||||||
|
name: fail2ban
|
||||||
|
enabled: yes
|
||||||
|
started: started
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
- include: apt.yml
|
||||||
|
tags:
|
||||||
|
- apt
|
||||||
|
- include: apticron.yml
|
||||||
|
tags:
|
||||||
|
- apticron
|
||||||
|
- include: disk-check.yml
|
||||||
|
tags:
|
||||||
|
- disk
|
||||||
|
- include: ufw.yml
|
||||||
|
tags:
|
||||||
|
- firewall
|
||||||
|
- include: fail2ban.yml
|
||||||
|
tags:
|
||||||
|
- firewall
|
||||||
|
- include: tools.yml
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
- name: ensure all tools packages are installed
|
||||||
|
apt:
|
||||||
|
pkg: "{{ packages }}"
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
cache_valid_time: 600
|
||||||
|
vars:
|
||||||
|
packages:
|
||||||
|
- curl
|
||||||
|
- debsums
|
||||||
|
- iperf3
|
||||||
|
- mosh
|
||||||
|
- net-tools
|
||||||
|
- needrestart
|
||||||
|
- sqlite3
|
||||||
|
- sudo
|
||||||
|
- tmux
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: allow ssh through firewall
|
||||||
|
ufw:
|
||||||
|
name: OpenSSH
|
||||||
|
rule: allow
|
||||||
|
- name: enable ufw firewall
|
||||||
|
command:
|
||||||
|
cmd: ufw enable
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# apticron.conf
|
||||||
|
#
|
||||||
|
# Set EMAIL to a space separated list of addresses which will be notified of
|
||||||
|
# impending updates. By default the root account will be notified.
|
||||||
|
|
||||||
|
EMAIL="root@{{ ansible_domain }}"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Check disk space
|
||||||
|
CURRENT=$(df / --output=pcent | tail --lines=1 | cut --delimiter='%' --field=1)
|
||||||
|
THRESHOLD=90
|
||||||
|
ADMIN="root@{{ ansible_domain }}"
|
||||||
|
SUBJECT="[Disk Space Alert] The free space on {{ ansible_fqdn }} is critically low"
|
||||||
|
MESSAGE=
|
||||||
|
|
||||||
|
if [ "$CURRENT" -gt "$THRESHOLD" ]; then
|
||||||
|
mail -s "$SUBJECT" "$ADMIN" << EOF
|
||||||
|
Your root partition remaining free space is critically low. Used: $CURRENT%
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
Reference in New Issue
Block a user