This repository contains Ansible playbooks and roles for setting up Docker, Nginx, and Rsyslog services. The project is structured to automate the deployment and configuration of these services using Ansible.
- ansible.cfg: Configuration file for Ansible.
- hosts.yml: Inventory file defining the hosts.
- playbooks/docker.yaml: Playbook for setting up Docker.
- playbooks/nginx.yml: Playbook for setting up Nginx.
- playbooks/rsyslog.yml: Playbook for setting up Rsyslog.
- defaults/main.yml: Default variables for Docker setup.
- tasks/config.yml: Tasks for configuring Docker.
- tasks/install.yml: Tasks for installing Docker.
- tasks/main.yml: Main task file for Docker setup.
- templates/daemon.j2: Jinja2 template for Docker daemon configuration.
Explanation: This role installs Docker on the target machine, configures it using the provided settings, and ensures that the Docker service is running.
- defaults/main.yml: Default variables for Nginx setup.
- files/.htpasswd: Password file for basic authentication.
- tasks/main.yml: Main task file for Nginx setup.
- templates/app.j2: Jinja2 template for Nginx application configuration.
- templates/compose.j2: Jinja2 template for Docker Compose configuration.
Explanation: This role installs Nginx on the target machine, configures it using the provided settings, and ensures that the Nginx service is running.
- defaults/main.yml: Default variables for Rsyslog setup.
- files/log/: Directory for log files.
- handlers/main.yml: Handlers for Rsyslog service.
- tasks/main.yml: Main task file for Rsyslog setup.
- templates/: Directory for Jinja2 templates.
Explanation: This role installs Rsyslog on the target machine, configures it using the provided settings, and ensures that the Rsyslog service is running.
- rpm_nginx.sh: Shell script for RPM-based Nginx installation.
- compose.yml: Docker Compose file.
- log_sender.service: Systemd service file for log sender.
- log_sender.sh: Shell script for log sender.
- logstash/pipeline/: Directory for Logstash pipeline configuration.
- rsyslog/Dockerfile: Dockerfile for Rsyslog.
- rsyslog/log.conf: Configuration file for Rsyslog.
Explanation: This directory contains additional configurations and scripts for setting up a logging infrastructure using Docker Compose, Logstash, and Rsyslog.
- compose.yml: Defines the services, networks, and volumes for the logging infrastructure. It includes configurations for Logstash and Rsyslog containers.
Explanation: This file orchestrates the deployment of multiple Docker containers, ensuring they are correctly configured and connected.
- rsyslog/Dockerfile: Defines the steps to build a Docker image for Rsyslog.
Explanation: This file contains the instructions to build a Docker image for Rsyslog, including installing necessary packages and copying configuration files.
- rsyslog/log.conf: Configuration file for Rsyslog.
Explanation: This file contains the configuration settings for Rsyslog, defining how logs are processed and where they are stored.
- log_sender.service: Systemd service file for log sender.
Explanation: This file defines a systemd service for the log sender script, ensuring it runs as a background service.
- log_sender.sh: Shell script for log sender.
Explanation: This script is responsible for sending logs to a specified destination. It is executed by the systemd service.
-
Clone the repository:
git clone https://github.com/yourusername/interview_tasks.git cd interview_tasks
-
Update the inventory file
hosts.yml
with your server details. -
Run the desired playbook:
ansible-playbook -i hosts.yml playbooks/nginx.yml
To use the ftp server on /var/log:
lftp ftp://rsyslog:StrongPassword1@ip
Hot Phase
Indices are kept in the hot phase for up to 7 days or until they reach 50GB in size.
Once these conditions are met, the index rolls over to a new index, allowing new data to continue being stored efficiently.
Warm Phase
After 7 days, the index transitions to the warm phase.
In this phase, the index undergoes a forcemerge to reduce the number of segments to 1. This helps reduce disk space usage and optimizes the index for read operations.
Delete Phase
After 180 days, the index enters the delete phase.
In this phase, the index is deleted to free up storage space, ensuring efficient use of system resources.