This repository contains a collection of Ansible playbooks for system administration and monitoring tasks.
Automated deployment and configuration of Zabbix Agent 2 on Linux systems.
Features:
- Multi-distribution support (Debian/Ubuntu and RedHat/CentOS)
- Automatic repository configuration
- Latest Zabbix Agent 2 installation
- Complete agent configuration
- Service management and validation
- Connectivity testing
Variables:
zabbix_server
: IP address of the Zabbix server (default: localhost)zabbix_agent_hostname
: Hostname for the agent (auto-detected)zabbix_agent_hostmetadata
: Host metadata (default: Linux)
Usage:
# Basic deployment
ansible-playbook deploy-zabbix-agent.yaml
# With custom Zabbix server
ansible-playbook deploy-zabbix-agent.yaml -e "zabbix_server=192.168.1.100"
Requirements:
- Ansible community.zabbix collection
- Target systems: Debian/Ubuntu or RedHat/CentOS
- Root privileges (become: true)
Updates all APT packages on Debian/Ubuntu systems.
Features:
- Updates package cache
- Upgrades all installed packages
- Safe and reliable package management
Usage:
ansible-playbook update-apt-packages.yaml
Removes unnecessary package dependencies on Debian/Ubuntu systems.
Features:
- Removes orphaned packages
- Cleans up system dependencies
- Frees up disk space
Usage:
ansible-playbook update-apt-autoremove.yaml
Combined Usage:
# Update packages then clean up
ansible-playbook update-apt-packages.yaml update-apt-autoremove.yaml
# Ubuntu/Debian
sudo apt update
sudo apt install ansible
# RHEL/CentOS
sudo yum install ansible
# or
sudo dnf install ansible
# Using pip
pip install ansible
For the Zabbix agent playbook:
ansible-galaxy collection install community.zabbix
Create an inventory file (hosts.ini
):
[servers]
server1 ansible_host=192.168.1.10 ansible_user=ubuntu
server2 ansible_host=192.168.1.11 ansible_user=ubuntu
[monitoring]
zabbix-server ansible_host=192.168.1.100 ansible_user=admin
# 1. Update all packages
ansible-playbook -i hosts.ini update-apt-packages.yaml
# 2. Clean up unnecessary packages
ansible-playbook -i hosts.ini update-apt-autoremove.yaml
# 3. Deploy Zabbix monitoring
ansible-playbook -i hosts.ini deploy-zabbix-agent.yaml -e "zabbix_server=192.168.1.100"
# Weekly maintenance
ansible-playbook -i hosts.ini update-apt-packages.yaml update-apt-autoremove.yaml
# Monthly monitoring setup
ansible-playbook -i hosts.ini deploy-zabbix-agent.yaml
- All playbooks require root privileges (
become: true
) - Ensure SSH key-based authentication is configured
- Limit inventory access to authorized systems only
- Review and test playbooks in development environment first
Zabbix Agent Deployment:
- Repository access: Ensure internet connectivity for package downloads
- Service startup: Check firewall rules for port 10050 (agent)
- Server connectivity: Verify Zabbix server is accessible on port 10051
APT Operations:
- Lock files: Ensure no other package managers are running
- Disk space: Verify sufficient space for package updates
- Network: Check internet connectivity for package downloads
Run playbooks with verbose output:
ansible-playbook -vvv playbook.yaml
# Test SSH connectivity
ansible all -i hosts.ini -m ping
# Check system information
ansible all -i hosts.ini -m setup
.
├── deploy-zabbix-agent.yaml # Zabbix agent deployment
├── update-apt-packages.yaml # APT package updates
├── update-apt-autoremove.yaml # APT cleanup
├── hosts.ini # Inventory file (example)
└── README.md # This file
- Test all playbooks in a development environment
- Follow Ansible best practices
- Document any new variables or requirements
- Ensure compatibility across supported distributions
These playbooks are provided as-is for educational and operational use. Please review and adapt according to your specific requirements and security policies.
For issues or questions:
- Review the troubleshooting section
- Check Ansible documentation: https://docs.ansible.com/
- Verify system requirements and dependencies