Stop Ansible from leaving your CI runners bloated with leftover state
By Saket Jain Published Linux/Unix
Stop Ansible from leaving your CI runners bloated with leftover state
Technical Briefing | 10/4/2026
CI runners are ephemeral by design, but anyone who has managed them knows they start accumulating junk after a few thousand jobs. Ansible is a common culprit here. It leaves behind temporary directories and control sockets that slowly eat up disk space or mess with file permissions. If your runner is a shared VM or a container that doesn’t get nuked between builds, this stuff sits there like a ticking time bomb.
Where the Ansible mess actually hides
By default, Ansible drops temporary files into .ansible/tmp inside the user’s home directory. That directory isn’t just full of scripts; it is full of specific module remnants that didn’t clean themselves up because a network hiccup killed the runner or a job timed out. If you have cron jobs running Ansible, these directories can eventually hit inode limits, which is the kind of silent failure that makes your monitoring look green while your pipeline is effectively dead.
find /home/runner/.ansible/tmp -type d -mtime +1 -exec rm -rf {} +
- Use the remote_tmp setting in ansible.cfg to point to a dedicated partition that you can safely wipe.
- Set ANSIBLE_REMOTE_TMP to a directory that gets mounted as a tmpfs to prevent disk write wear.
- Check your runner cleanup scripts for leftover control sockets in the tmp folder if you use SSH multiplexing.
If you are running Ansible locally via a CI runner, consider setting ANSIBLE_KEEP_REMOTE_FILES to False explicitly in your environment. Most people skip this, but it forces Ansible to be more aggressive about removing execution artifacts. Keep an eye on your disk usage metrics for the runner user specifically, not just the root filesystem, because that is where the real horror usually hides.
