Add ability to specify syslog facility for modules

Update constants.py so that one can specify environmental variable
ANSIBLE_SYSLOG_FACILITY or syslog_facility in ansible.cfg to define
the syslog facility to use.  Alternatively, you can specify
ansible_syslog_facility in inventory.  Runner now replaces
the syslog facility in the openlog() call with the default or
the injected variables ansible_syslog_facility.

This also updates hacking/test-module to behave similarly.
This commit is contained in:
Stephen Fromm
2012-11-09 22:13:00 -08:00
parent 40e49b6a5a
commit 06e54c0b97
4 changed files with 9 additions and 1 deletions

View File

@@ -35,6 +35,7 @@ import traceback
import optparse
import ansible.utils as utils
import ansible.module_common as module_common
import ansible.constants as C
try:
import json
@@ -83,6 +84,7 @@ def boilerplate_module(modfile, args):
module_data = module_data.replace(module_common.REPLACER, module_common.MODULE_COMMON)
encoded_args = "\"\"\"%s\"\"\"" % args.replace("\"","\\\"")
module_data = module_data.replace(module_common.REPLACER_ARGS, encoded_args)
module_data = module_data.replace('syslog.LOG_USER', "syslog.%s" % C.DEFAULT_SYSLOG_FACILITY)
modfile2_path = os.path.expanduser("~/.ansible_module_generated")
print "* including generated source, if any, saving to: %s" % modfile2_path