Stop your Ansible temporary files from cluttering up /tmp on remote hosts

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

Stop your Ansible temporary files from cluttering up /tmp on remote hosts

Technical Briefing | 8/22/2026

Most of us run Ansible playbooks and assume that when the task finishes, everything it touched on the remote side disappears. For the most part, it does. But if you have been managing high-traffic runners or tight disk quotas on your target nodes, you have probably noticed the mysterious accumulation of files in /tmp/ansible-tmp-*. This bit me once during a production deploy when an old mount point filled up and brought the node to its knees because Ansible left behind a mountain of Python wrappers.

Why Ansible keeps leaving digital litter

When you execute a task, Ansible creates a temporary directory, copies the module code over, and runs it. Usually, the connection plugin cleans this up immediately after completion. But if your persistent connections time out, or if the user running the task doesn’t have the permissions to clean up its own residue, those files sit there indefinitely. Over months, this turns into thousands of inodes gone and several gigabytes of wasted space.

find /tmp -maxdepth 1 -user ansible_user -name 'ansible-tmp-*' -mtime +1 -exec rm -rf {} +

  • Check your remote user permissions to ensure it owns the directory tree
  • Set remote_tmp in your ansible.cfg to a dedicated partition if /tmp is volatile
  • Use a cron job to prune those directories if your CI/CD pipeline runs thousands of tasks an hour

Don’t bother looking for a native setting that magically prevents this; the architecture relies on these temporary files for execution. Instead, just treat your target nodes like any other system that produces garbage. A simple maintenance script running once a day is the only way to keep your disk usage sane without fighting the tool’s fundamental design. If your disk is still filling up after that, check if your connection plugin is hitting unexpected SSH timeouts.

Linux Admin Automation  |  © www.ngelinux.com  |  8/22/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted