Clearing Rails Log Files on AWS with Ansible

Dec 2, 2016

If you are reading this and you’ve read more than a few things I’ve written then you know that I’m, well, a wordy son of a bitch. I mean come on – did you see the post on AWS Partition Resizing? I took like 7800 words to say “can’t do it” – apologies.

Anyway the digression into wordiness is because like me, Rails log files are wordy son’s of bitches – the number of times in my career that I’ve had to log into a box and do the log dance:

bundle exec rake log:clear

has to be measured in the hundreds if not thousands. This morning I finally got mad enough to automate it with Ansible. Here’s how:

Right now this is working with a static inventory file. If anyone expresses interest, on Monday, I’ll publish a revised version which uses the python boto module to clear log files based on all boxes on EC2 dynamically matching a criteria like a name tag.