GPT for Sysadmin Automation

Use ChatGPT and LLMs to automate repetitive sysadmin tasks — cron jobs, alerting, and IaC generation.

Category: AI / GPT

Where AI Saves Sysadmins Time

  • Generating bash and Python scripts from descriptions
  • Writing Ansible playbooks and Terraform configs
  • Drafting cron jobs and systemd timers
  • Creating monitoring alert rules (Grafana, Prometheus)
  • Documenting runbooks and SOPs

Practical Prompts

Generate a Backup Script

Write a bash script that:
- Backs up /var/www to /mnt/backups/ with a date-stamped filename
- Keeps only the last 7 backups
- Logs success or failure to /var/log/backup.log
- Sends an email alert if the backup fails

Generate an Ansible Playbook

Write an Ansible playbook that:
- Installs nginx and certbot on Ubuntu 22.04
- Configures nginx as a reverse proxy for port 3000
- Obtains a Let's Encrypt SSL certificate for myapp.example.com
- Enables and starts the nginx service

Explain a Log Entry

Explain this syslog entry and suggest what to investigate:
May 30 14:23:11 web01 kernel: [UFW BLOCK] IN=eth0 OUT= SRC=185.220.101.45 DST=10.0.0.10 ...

Tips for Better Results

  • Be specific: include OS version, distro, and exact requirements
  • Paste real examples: give GPT your actual config file or log line
  • Iterate: ask “make it production-safe” or “add error handling” as follow-ups
  • Verify output: always test scripts in a staging environment first