diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 9b36df04f02..7d7c7da5820 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -48,12 +48,10 @@ def load_callback_plugins(): callback_plugins = [x for x in utils.plugins.callback_loader.all()] def get_cowsay_info(): - if constants.ANSIBLE_NOCOWS is not None: + if constants.ANSIBLE_NOCOWS: return (None, None) cowsay = None - if os.getenv("ANSIBLE_NOCOWS") is not None: - cowsay = None - elif os.path.exists("/usr/bin/cowsay"): + if os.path.exists("/usr/bin/cowsay"): cowsay = "/usr/bin/cowsay" elif os.path.exists("/usr/games/cowsay"): cowsay = "/usr/games/cowsay" diff --git a/lib/ansible/color.py b/lib/ansible/color.py index 0266ea57ade..304967993ca 100644 --- a/lib/ansible/color.py +++ b/lib/ansible/color.py @@ -20,7 +20,7 @@ import sys import constants ANSIBLE_COLOR=True -if constants.ANSIBLE_NOCOLOR is not None: +if constants.ANSIBLE_NOCOLOR: ANSIBLE_COLOR=False elif not hasattr(sys.stdout, 'isatty') or not sys.stdout.isatty(): ANSIBLE_COLOR=False diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 3b93de14c1d..dc788b71e89 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -22,6 +22,8 @@ import ConfigParser # copied from utils, avoid circular reference fun :) def mk_boolean(value): + if value is None: + return False val = str(value) if val.lower() in [ "true", "t", "y", "1", "yes" ]: return True @@ -125,8 +127,8 @@ DEFAULT_VARS_PLUGIN_PATH = get_config(p, DEFAULTS, 'vars_plugins', ' DEFAULT_FILTER_PLUGIN_PATH = get_config(p, DEFAULTS, 'filter_plugins', 'ANSIBLE_FILTER_PLUGINS', '/usr/share/ansible_plugins/filter_plugins') DEFAULT_LOG_PATH = shell_expand_path(get_config(p, DEFAULTS, 'log_path', 'ANSIBLE_LOG_PATH', '')) -ANSIBLE_NOCOLOR = get_config(p, DEFAULTS, 'nocolor', 'ANSIBLE_NOCOLOR', None) -ANSIBLE_NOCOWS = get_config(p, DEFAULTS, 'nocows', 'ANSIBLE_NOCOWS', None) +ANSIBLE_NOCOLOR = get_config(p, DEFAULTS, 'nocolor', 'ANSIBLE_NOCOLOR', None, boolean=True) +ANSIBLE_NOCOWS = get_config(p, DEFAULTS, 'nocows', 'ANSIBLE_NOCOWS', None, boolean=True) ANSIBLE_SSH_ARGS = get_config(p, 'ssh_connection', 'ssh_args', 'ANSIBLE_SSH_ARGS', None) PARAMIKO_RECORD_HOST_KEYS = get_config(p, 'paramiko_connection', 'record_host_keys', 'ANSIBLE_PARAMIKO_RECORD_HOST_KEYS', True, boolean=True) ZEROMQ_PORT = int(get_config(p, 'fireball_connection', 'zeromq_port', 'ANSIBLE_ZEROMQ_PORT', 5099))