Ansible, a suite of software tools that enables infrastructure as code.
Ansible playbooks for my personal use. Tested in my production environment.
- Servers — Debian based systems
- Laptop — Arch based systems
- Package Management — Install, remove, and update packages via apt
- Service Control — Start, stop, and restart systemd services
- System Operations — Reboot, shutdown, and gather system info
- Multi-host Support — Target single hosts, groups, or patterns with
--limit
On target servers:
sudo apt install openssh-serverOn Ansible host (Arch Linux):
pacman -S ansible-coreansible all -m ping --limit <HOST># Update and upgrade servers
ansible-playbook apt-update_pb.yml --limit webservers -K
# Install packages
ansible-playbook apt-install_pb.yml --limit raspi -K -e "packages=['htop','curl']"
# Remove packages
ansible-playbook apt-remove_pb.yml --limit dbservers -K -e "packages=nginx"
# Restart a service
ansible-playbook service-restart_pb.yml --limit webservers -K -e "service=postfix"
# Get system info
ansible-playbook system-info_pb.yml --limit cluster
# Dry run (check mode)
ansible-playbook apt-update_pb.yml --limit all -K --check| Flag | Description |
|---|---|
-K |
Prompt for sudo password |
-i |
Path to inventory file |
--limit |
Target specific hosts/groups |
--check |
Dry run (no changes) |
-e |
Pass extra variables |
ansible-inventory --graph -i hostsansible/
├── apt-install_pb.yml # Install packages
├── apt-remove_pb.yml # Remove packages
├── apt-update_pb.yml # Update & upgrade system
├── ping_pb.yml # Test connectivity
├── reboot_pb.yml # Reboot servers
├── shutdown_pb.yml # Shutdown servers
├── service-start_pb.yml # Start services
├── service-stop_pb.yml # Stop services
├── service-restart_pb.yml # Restart services
└── system-info_pb.yml # Display system information
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or need support, please file an issue on the GitHub repository.
This project is licensed under the GNU GENERAL PUBLIC LICENSE v3.0 - see the LICENSE file for details.