Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to continuously tail remote files using ansible?

Tags:

tail

ansible

How is it possible to tail a file located at several remote servers in a known location using ansible? This question is based on this comment on this Hacker News thread:

In my company, we have hundred machines and tailing done with ansible. If we want customize the log view, we can simply edit the playbook. I think it is very handy compared to we need additional npm package (and not to mention additional effort for customization).

like image 250
neowulf33 Avatar asked Nov 12 '15 02:11

neowulf33


1 Answers

You can use ansible ad-hoc :

 ansible atlanta -a "tail /homedir/myfile" -f 10

UPDATE

Ansible can only print the output after completing the command. That's why I think what you want is not possible, ansible is probably not the tool you want for this job. Check issue 4870 and 3887.

If you really want to use ansible to do this, there is hack posted in one of issues (haven't tested and actually I don't recommend it).

I really don't know what the guy from HN was talking about, maybe just tail (without the -f)?

like image 151
Onilton Maciel Avatar answered Sep 21 '22 09:09

Onilton Maciel