|
|
|
@ -55,6 +55,13 @@ try:
|
|
|
|
|
except ImportError:
|
|
|
|
|
from md5 import md5 as _md5
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from systemd import journal
|
|
|
|
|
has_journal = True
|
|
|
|
|
except ImportError:
|
|
|
|
|
import syslog
|
|
|
|
|
has_journal = False
|
|
|
|
|
|
|
|
|
|
class AnsibleModule(object):
|
|
|
|
|
|
|
|
|
|
def __init__(self, argument_spec, bypass_checks=False, no_log=False,
|
|
|
|
@ -198,11 +205,26 @@ class AnsibleModule(object):
|
|
|
|
|
|
|
|
|
|
def _log_invocation(self):
|
|
|
|
|
''' log that ansible ran the module '''
|
|
|
|
|
# Sanitize possible password argument when logging.
|
|
|
|
|
log_args = dict()
|
|
|
|
|
passwd_keys = ['password', 'login_password']
|
|
|
|
|
for param in self.params:
|
|
|
|
|
if param in passwd_keys:
|
|
|
|
|
log_args[param] = 'NOT_LOGGING_PASSWORD'
|
|
|
|
|
else:
|
|
|
|
|
log_args[param] = self.params[param]
|
|
|
|
|
|
|
|
|
|
if (has_journal):
|
|
|
|
|
journal_args = ["MESSAGE=Ansible module invoked", "MODULE=%s" % os.path.basename(__file__)]
|
|
|
|
|
for arg in log_args:
|
|
|
|
|
journal_args.append(arg.upper() + "=" + str(log_args[arg]))
|
|
|
|
|
journal.sendv(*journal_args)
|
|
|
|
|
else:
|
|
|
|
|
msg = ''
|
|
|
|
|
syslog.openlog('ansible-%s' % os.path.basename(__file__))
|
|
|
|
|
# Sanitize possible password argument when logging
|
|
|
|
|
log_args = re.sub(r'password=.+ (.*)', r"password=NOT_LOGGING_PASSWORD \1", self.args)
|
|
|
|
|
log_args = re.sub(r'login_password=.+ (.*)', r"login_password=NOT_LOGGING_PASSWORD \1", log_args)
|
|
|
|
|
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % log_args)
|
|
|
|
|
for arg in log_args:
|
|
|
|
|
msg = msg + arg + '=' + str(log_args[arg]) + ' '
|
|
|
|
|
syslog.syslog(syslog.LOG_NOTICE, 'Invoked with %s' % msg)
|
|
|
|
|
|
|
|
|
|
def get_bin_path(self, arg, required=False, opt_dirs=[]):
|
|
|
|
|
'''
|
|
|
|
|