feat: enhance Ansible playbook and Nginx configuration with authentication and logrotate setup

- Added environment variables for project configuration in env.template.
- Updated Ansible playbook to use environment variables for project settings and added tasks for monitoring authentication setup.
- Enhanced Nginx configuration for Alertmanager and Prometheus with HTTP Basic Authentication.
- Introduced logrotate configuration for managing log files and set up cron for daily execution.
- Removed obsolete Uptime Kuma docker-compose file.
This commit is contained in:
2025-09-19 12:09:05 +03:00
parent 1eb11e454d
commit f7b08ae9e8
16 changed files with 959 additions and 51 deletions

View File

@@ -0,0 +1,49 @@
# Logrotate configuration for bot applications
# This file manages log rotation for all bot services
{{ project_root }}/bots/*/logs/*.log {
daily
missingok
rotate {{ lookup('env', 'LOGROTATE_RETENTION_DAYS') | default('30') }}
{% if lookup('env', 'LOGROTATE_COMPRESS') | default('true') | lower == 'true' %}compress{% endif %}
{% if lookup('env', 'LOGROTATE_DELAYCOMPRESS') | default('true') | lower == 'true' %}delaycompress{% endif %}
notifempty
create 0644 {{ deploy_user }} {{ deploy_user }}
postrotate
# Restart bot services if they are running
if [ -f /home/{{ deploy_user }}/.docker-compose-pid ]; then
cd {{ project_root }} && docker-compose restart
fi
endscript
}
{{ project_root }}/bots/*/bot_stderr.log {
daily
missingok
rotate {{ lookup('env', 'LOGROTATE_RETENTION_DAYS') | default('30') }}
{% if lookup('env', 'LOGROTATE_COMPRESS') | default('true') | lower == 'true' %}compress{% endif %}
{% if lookup('env', 'LOGROTATE_DELAYCOMPRESS') | default('true') | lower == 'true' %}delaycompress{% endif %}
notifempty
create 0644 {{ deploy_user }} {{ deploy_user }}
postrotate
# Restart bot services if they are running
if [ -f /home/{{ deploy_user }}/.docker-compose-pid ]; then
cd {{ project_root }} && docker-compose restart
fi
endscript
}
# Docker container logs
/var/lib/docker/containers/*/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 0644 root root
postrotate
# Reload Docker daemon
systemctl reload docker
endscript
}