Initial template repository
🎬 ARR Suite Template Bootstrap - Complete Media Automation Stack Features: - 16 production services (Prowlarr, Sonarr, Radarr, Plex, etc.) - One-command Ansible deployment - VPN-protected downloads via Gluetun - Tailscale secure access - Production-ready security (UFW, Fail2Ban) - Automated backups and monitoring - Comprehensive documentation Ready for customization and deployment to any VPS. Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
260
tasks/monitoring_setup.yml
Normal file
260
tasks/monitoring_setup.yml
Normal file
@@ -0,0 +1,260 @@
|
||||
---
|
||||
# Monitoring and logging setup tasks
|
||||
|
||||
- name: Create monitoring directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ docker_user }}"
|
||||
group: "{{ docker_group }}"
|
||||
mode: '0755'
|
||||
loop:
|
||||
- "{{ docker_root }}/monitoring"
|
||||
- "{{ docker_root }}/logs"
|
||||
- "{{ docker_root }}/logs/arrs"
|
||||
- "{{ docker_root }}/logs/system"
|
||||
tags: ['monitoring_dirs']
|
||||
|
||||
- name: Install monitoring tools
|
||||
apt:
|
||||
name:
|
||||
- htop
|
||||
- iotop
|
||||
- nethogs
|
||||
- ncdu
|
||||
- tree
|
||||
- lsof
|
||||
- strace
|
||||
- tcpdump
|
||||
- nmap
|
||||
state: present
|
||||
tags: ['monitoring_tools']
|
||||
|
||||
- name: Create monitoring scripts directory
|
||||
file:
|
||||
path: /usr/local/bin
|
||||
state: directory
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Create monitoring log directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
loop:
|
||||
- /var/log/arrs
|
||||
- /opt/monitoring
|
||||
- /opt/monitoring/scripts
|
||||
tags: ['monitoring_dirs']
|
||||
|
||||
- name: Deploy health dashboard script
|
||||
template:
|
||||
src: health-dashboard.sh.j2
|
||||
dest: /usr/local/bin/health-dashboard.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Deploy system monitoring script
|
||||
template:
|
||||
src: system-monitor.sh.j2
|
||||
dest: /usr/local/bin/system-monitor.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Deploy Docker monitoring script
|
||||
template:
|
||||
src: docker-monitor.sh.j2
|
||||
dest: /usr/local/bin/docker-monitor.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Deploy network monitoring script
|
||||
template:
|
||||
src: network-monitor.sh.j2
|
||||
dest: /usr/local/bin/network-monitor.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Deploy performance monitoring script
|
||||
template:
|
||||
src: performance-monitor.sh.j2
|
||||
dest: /usr/local/bin/performance-monitor.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Deploy security audit script
|
||||
template:
|
||||
src: security-audit.sh.j2
|
||||
dest: /usr/local/bin/security-audit.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Deploy disk usage monitoring script
|
||||
template:
|
||||
src: disk-usage-monitor.sh.j2
|
||||
dest: /usr/local/bin/disk-usage-monitor.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Deploy service health check script
|
||||
template:
|
||||
src: check-services.sh.j2
|
||||
dest: /usr/local/bin/check-services.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Deploy log aggregator script
|
||||
template:
|
||||
src: log-aggregator.sh.j2
|
||||
dest: /usr/local/bin/log-aggregator.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
|
||||
|
||||
- name: Set up log rotation for Arrs applications
|
||||
template:
|
||||
src: arrs-logrotate.j2
|
||||
dest: /etc/logrotate.d/arrs
|
||||
mode: '0644'
|
||||
tags: ['log_rotation']
|
||||
|
||||
- name: Add health dashboard alias to root bashrc
|
||||
lineinfile:
|
||||
path: /root/.bashrc
|
||||
line: "alias health='/usr/local/bin/health-dashboard.sh'"
|
||||
create: yes
|
||||
tags: ['monitoring_scripts']
|
||||
|
||||
- name: Set up cron job for system monitoring
|
||||
cron:
|
||||
name: "System monitoring"
|
||||
minute: "*/10"
|
||||
job: "/usr/local/bin/system-monitor.sh >> /var/log/arrs/system-monitor.log 2>&1"
|
||||
user: root
|
||||
tags: ['monitoring_cron']
|
||||
|
||||
- name: Set up cron job for Docker monitoring
|
||||
cron:
|
||||
name: "Docker monitoring"
|
||||
minute: "*/5"
|
||||
job: "/usr/local/bin/docker-monitor.sh >> /var/log/arrs/docker-monitor.log 2>&1"
|
||||
user: root
|
||||
tags: ['monitoring_cron']
|
||||
|
||||
- name: Set up cron job for network monitoring
|
||||
cron:
|
||||
name: "Network monitoring"
|
||||
minute: "*/15"
|
||||
job: "/usr/local/bin/network-monitor.sh >> /var/log/arrs/network-monitor.log 2>&1"
|
||||
user: root
|
||||
tags: ['monitoring_cron']
|
||||
|
||||
- name: Set up cron job for performance monitoring
|
||||
cron:
|
||||
name: "Performance monitoring"
|
||||
minute: "*/20"
|
||||
job: "/usr/local/bin/performance-monitor.sh >> /var/log/arrs/performance-monitor.log 2>&1"
|
||||
user: root
|
||||
tags: ['monitoring_cron']
|
||||
|
||||
- name: Set up cron job for security audit
|
||||
cron:
|
||||
name: "Security audit"
|
||||
minute: "0"
|
||||
hour: "2"
|
||||
job: "/usr/local/bin/security-audit.sh >> /var/log/arrs/security-audit.log 2>&1"
|
||||
user: root
|
||||
tags: ['monitoring_cron']
|
||||
|
||||
- name: Set up cron job for disk usage monitoring
|
||||
cron:
|
||||
name: "Disk usage monitoring"
|
||||
minute: "0"
|
||||
hour: "*/6"
|
||||
job: "/usr/local/bin/disk-usage-monitor.sh >> /var/log/arrs/disk-usage.log 2>&1"
|
||||
user: root
|
||||
tags: ['monitoring_cron']
|
||||
|
||||
- name: Set up cron job for service health checks
|
||||
cron:
|
||||
name: "Service health checks"
|
||||
minute: "*/5"
|
||||
job: "/usr/local/bin/check-services.sh >> /var/log/arrs/service-checks.log 2>&1"
|
||||
user: root
|
||||
tags: ['monitoring_cron']
|
||||
|
||||
- name: Set up cron job for log aggregation
|
||||
cron:
|
||||
name: "Log aggregation"
|
||||
minute: "0"
|
||||
hour: "1"
|
||||
job: "/usr/local/bin/log-aggregator.sh >> /var/log/arrs/log-aggregator.log 2>&1"
|
||||
user: root
|
||||
tags: ['monitoring_cron']
|
||||
|
||||
- name: Create alerting script
|
||||
template:
|
||||
src: alert-manager.sh.j2
|
||||
dest: "{{ docker_root }}/scripts/alert-manager.sh"
|
||||
owner: "{{ docker_user }}"
|
||||
group: "{{ docker_group }}"
|
||||
mode: '0755'
|
||||
tags: ['alerting']
|
||||
|
||||
- name: Configure rsyslog for centralized logging
|
||||
template:
|
||||
src: rsyslog-arrs.conf.j2
|
||||
dest: /etc/rsyslog.d/40-arrs.conf
|
||||
mode: '0644'
|
||||
notify: restart rsyslog
|
||||
tags: ['centralized_logging']
|
||||
|
||||
- name: Create log analysis script
|
||||
template:
|
||||
src: log-analyzer.sh.j2
|
||||
dest: "{{ docker_root }}/scripts/log-analyzer.sh"
|
||||
owner: "{{ docker_user }}"
|
||||
group: "{{ docker_group }}"
|
||||
mode: '0755'
|
||||
tags: ['log_analysis']
|
||||
|
||||
- name: Set up weekly log analysis cron job
|
||||
cron:
|
||||
name: "Weekly log analysis"
|
||||
minute: "0"
|
||||
hour: "2"
|
||||
weekday: "0"
|
||||
job: "{{ docker_root }}/scripts/log-analyzer.sh >> {{ docker_root }}/logs/system/log-analysis.log 2>&1"
|
||||
user: "{{ docker_user }}"
|
||||
tags: ['log_analysis']
|
||||
|
||||
- name: Create monitoring configuration file
|
||||
template:
|
||||
src: monitoring.conf.j2
|
||||
dest: "{{ docker_root }}/monitoring/monitoring.conf"
|
||||
owner: "{{ docker_user }}"
|
||||
group: "{{ docker_group }}"
|
||||
mode: '0644'
|
||||
tags: ['monitoring_config']
|
||||
Reference in New Issue
Block a user