simple logging setup using logger.
/usr/bin/logger should probably be a constant or defined in some sort of config as well as the log priority
This commit is contained in:
parent
e25bb2f888
commit
e7bb41ff89
1 changed files with 7 additions and 0 deletions
|
@ -120,6 +120,7 @@ class Runner(object):
|
||||||
return [ host, True, json.loads(result) ]
|
return [ host, True, json.loads(result) ]
|
||||||
else:
|
else:
|
||||||
# SFTP file copy module is not really a module
|
# SFTP file copy module is not really a module
|
||||||
|
self.remote_log(conn, 'COPY remote:%s local:%s' % (self.module_args[0], self.module_args[1]))
|
||||||
ftp = conn.open_sftp()
|
ftp = conn.open_sftp()
|
||||||
ftp.put(self.module_args[0], self.module_args[1])
|
ftp.put(self.module_args[0], self.module_args[1])
|
||||||
ftp.close()
|
ftp.close()
|
||||||
|
@ -132,8 +133,14 @@ class Runner(object):
|
||||||
cmd = "%s %s" % (outpath, " ".join(self.module_args))
|
cmd = "%s %s" % (outpath, " ".join(self.module_args))
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
|
def remote_log(self, conn, msg):
|
||||||
|
stdin, stdout, stderr = conn.exec_command('/usr/bin/logger -t ansible -p auth.info %r' % msg)
|
||||||
|
|
||||||
def _exec_command(self, conn, cmd):
|
def _exec_command(self, conn, cmd):
|
||||||
''' execute a command over SSH '''
|
''' execute a command over SSH '''
|
||||||
|
msg = '%s: %s' % (self.module_name, cmd)
|
||||||
|
self.remote_log(conn, msg)
|
||||||
stdin, stdout, stderr = conn.exec_command(cmd)
|
stdin, stdout, stderr = conn.exec_command(cmd)
|
||||||
results = "\n".join(stdout.readlines())
|
results = "\n".join(stdout.readlines())
|
||||||
return results
|
return results
|
||||||
|
|
Loading…
Reference in a new issue