Can I make Rundeck read a log file on the remote node as job output?

1.9k views Asked by At

I'm using Rundeck to run remote jobs through the SSH executor. Some of the jobs I run log to specific files on the host, rather than STDOUT, and I don't have the ability to change this.

Is there any way to tell Rundeck to read those files as they get written (using something like tail -f), and treat what appears there as the job output?

Adding tail -f itself as a step wouldn't work, since it will never terminate.

If need be, a 'hacky' solution will do (like adding extra job steps for copying and reading logs) but ideally I'd like it to be neater. So if you could give me some guidelines how to build a plugin that will take the filename as a parameter and read the output from there, that would be better.

1

There are 1 answers

5
Leo Prince On

If you just want a file to read and print on STDOUT, then just use this inline script as additional step in workflow.

#!/usr/bin/python
import os,sys
file_name=sys.argv[1]
if os.path.isfile(file_name):
    with open(file_name) as file:
        for line in file:
            print line
else:
    print 'file doesnt exists'

Give file name as argument