A collection of Ansible Playbooks created and used during my learning journey with Ansible.
This repository contains a variety of Ansible playbooks that automate different system administration tasks. Each playbook is organized by category for easy navigation.
To run any of these playbooks, use the following command:
ansible-playbook path/to/playbook.yml -i your_inventory_file-
APT Setup Unattended Upgrades: This playbook installs the
unattended-upgradespackage and configures your system to receive automatic updates for enhanced security and stability. -
Disable Phased Updates: This playbook disables APT phased updates by writing a configuration file to
/etc/apt/apt.conf.d/. -
APT Packages Upgrade: This playbook upgrades all installed APT packages to their latest versions, keeping your system up-to-date.
- Install Caddy Server: This playbook installs the custom Caddy web server build from caddy.devjugal.com with essential plugins for DNS challenges, distributed storage, and compression.
- Upgrade Cloudflared: This playbook upgrades the installed Cloudflared package to the latest version, ensuring you have the latest features and security patches.
-
Docker Cleanup: This playbook runs
docker system prune -fto remove unused Docker data, including stopped containers, networks, images, and the build cache, thus freeing up disk space. -
Deploy Docker Prune Timer: This playbook creates a Systemd Service/Timer for weekly pruning of unused Docker objects, ensuring that your Docker environment remains clean.
-
Install Docker & Docker Compose: This playbook installs Docker and Docker Compose, providing a robust platform for containerized applications.
-
Configure Docker Daemon: This playbook writes a
daemon.jsonwith log rotation settings (max-size 50m, max-file 5) and other Docker daemon options.
- Setup Fail2ban: This playbook installs Fail2ban and configures it to protect your server from brute-force attacks, particularly on SSH connections.
- Generate Report: This playbook generates GoAccess report for Caddy Server.
-
Restic Backup: This playbook performs a Restic backup, initializing the repository if needed, and then executing the backup with specified paths and tags.
-
Restic Forget/Prune: This playbook runs the
restic forgetcommand to remove old backups based on a retention policy and then prunes the repository to reclaim space.
-
Install Caddy Server: This playbook installs Caddy Server from the official Cloudsmith repository.
-
Install Dockmon Agent: This playbook installs and configures the Dockmon agent along with its docker-compose setup.
-
Install GoAccess: This playbook install GoAccess.
-
Install Nginx: This playbook install Nginx Web Server.
-
Install q: This playbook installs
q, a powerful command-line DNS client, facilitating better DNS querying. -
Install Rclone: This playbook installs Rclone, a command-line program to manage files on cloud storage.
-
Install Restic: This playbook installs Restic, a program that allows you to backup your files.
-
Install Autorestic: This playbook installs Autorestic, a wrapper around Restic that simplifies configuring and running backups.
-
Install Sendme: This playbook installs Sendme, a peer-to-peer file transfer tool built on iroh. Pin a version with
-e sendme_version=v0.36.0to skip the GitHub API call. -
Install Zoxide: This playbook installs Zoxide, a command-line tool that provides a fuzzy finder for directories.
- NTP - Setup Time Synchronization: This playbook installs and configures NTP to keep your server's time synchronized accurately with global time standards.
-
Install Blackbox Exporter: This playbook installs the Blackbox Exporter, which allows you to collect and report network metrics such as ICMP, HTTP, etc.
-
Install Fail2ban Exporter: This playbook installs the Fail2ban Exporter, which allows you to collect and report fail2ban metrics.
-
Install Node Exporter: This playbook installs the Node Exporter, which allows you to collect and report hardware and OS metrics exposed by the Linux operating system.
-
Install Smartctl Exporter: This playbook installs the Smartctl Exporter, which allows you to collect and report SMART metrics.
-
Install Systemd Exporter: This playbook installs the Systemd Exporter, which allows you to collect and report systemd metrics.
-
Install ZFS Exporter: This playbook installs the ZFS Exporter, which allows you to collect and report ZFS pool, dataset, and volume metrics.
- Server Inventory Report: This playbook collects and displays a comprehensive inventory report of your servers, including OS, virtualization type, architecture, CPU cores, RAM, disk size, and uptime.
- Install Speedtest: This playbook installs the official CLI from Speedtest.net, allowing you to easily test and measure your internet connection performance.
- SSH Keys: This playbook adds desired SSH Keys either from GitHub or manually from ssh_keys/vars/keys.yml.
-
TCP Tweaks: This playbook increases system-wide and per-connection buffer limits to 128MB. It tunes
net.core.rmem_max,net.core.wmem_max,net.ipv4.tcp_rmem, andnet.ipv4.tcp_wmemto improve performance on high-bandwidth links. -
UDP Buffer Size: This playbook increases UDP receive and send buffer sizes to ~7.5MB to optimize QUIC transfer speeds. It sets
net.core.rmem_maxandnet.core.wmem_max.
-
Create User & Disable Root Login: This playbook creates a user (defaults to
jungle) and disables root login for enhanced security of your server. -
Upgrade & Install Essential Packages: This playbook sets up your server by installing essential packages, ensuring that your Ubuntu system is ready for basic operations.
- Setup vnStat and Cron Job: This playbook installs vnStat and configures a cron job to update traffic statistics every minute, saving the output to a specified file.
Ensure you review each playbook and update any necessary variables according to your environment specifics before running them. This will help in avoiding unintended changes to your systems.