Stop letting your Ansible CI runner dump temporary files everywhere

DevOps Tooling On Linux (CI/CD Runners, Ansible)

Stop letting your Ansible CI runner dump temporary files everywhere

Technical Briefing | 10/21/2026

Every time you run an Ansible playbook through a CI runner like GitLab or GitHub Actions, it spins up a shell and creates a mess of temporary directories. Most people don’t notice until their runner partition hits 100 percent usage because Ansible leaves behind cached fact files and connection control sockets. I’ve spent an entire afternoon tracking down a storage leak only to find five thousand leftover sockets in /tmp.

Cleaning up the artifacts before the disk fills up

You shouldn’t be manually cleaning these up. The standard approach is to point your environment variables to a dedicated directory that you can easily purge during your runner’s cleanup phase. Don’t rely on the default location, as it’s often shared with other system processes that might get cranky if you run a blanket find command.

export ANSIBLE_LOCAL_TEMP=/var/cache/ansible/tmp
export ANSIBLE_REMOTE_TEMP=/var/cache/ansible/tmp
find /var/cache/ansible/tmp -type d -mmin +60 -exec rm -rf {} +

  • Use a specific mount point for runner cache to prevent system-wide disk pressure
  • Set the ANSIBLE_REMOTE_TEMP variable to ensure connection sockets have a predictable home
  • Add a pre-job cleanup script to remove old socket files that stalled processes failed to unlink

If you’re using a systemd-based runner service, look into the PrivateTmp directive. It isolates the runner from the rest of your system’s temp space, making cleanup as easy as restarting the service. That way, the next time your playbooks churn through data, you aren’t hunting for stray files across your entire root partition.

Linux Admin Automation  |  © www.ngelinux.com  |  10/21/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted