summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2014-04-30 14:44:10 -0500
committerJames Cammarata <jimi@sngx.net>2014-04-30 14:44:10 -0500
commit6069ff6e9e3a7debe3174bbee02d4880ad642ab0 (patch)
tree69d82ebbdc719bcfaa7007f9cef567eb0576d3e1
parentbf7c51ad8a10f32afb0a9ffd736dc7a0d183cf17 (diff)
downloadansible-6069ff6e9e3a7debe3174bbee02d4880ad642ab0.tar.gz
Adding a new system_warnings config option to supress warnings
-rw-r--r--docsite/rst/intro_configuration.rst13
-rw-r--r--examples/ansible.cfg11
-rw-r--r--lib/ansible/constants.py1
-rw-r--r--lib/ansible/utils/__init__.py12
4 files changed, 34 insertions, 3 deletions
diff --git a/docsite/rst/intro_configuration.rst b/docsite/rst/intro_configuration.rst
index f37ba6012c..6337e5cf3f 100644
--- a/docsite/rst/intro_configuration.rst
+++ b/docsite/rst/intro_configuration.rst
@@ -477,6 +477,19 @@ playbook. The default is the most logical: 'root'::
sudo_user=root
+.. _system_warnings:
+
+system_warnings
+===============
+
+.. versionadded:: 1.6
+
+Allows disabling of warnings related to potential issues on the system running ansible itself (not on the managed hosts)::
+
+ system_warnings = True
+
+These may include warnings about 3rd party packages or other conditions that should be resolved if possible.
+
.. _timeout:
timeout
diff --git a/examples/ansible.cfg b/examples/ansible.cfg
index 6e297d4f0e..e6bc86cffb 100644
--- a/examples/ansible.cfg
+++ b/examples/ansible.cfg
@@ -91,6 +91,17 @@ ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid}
# to revert the behavior to pre-1.3.
#error_on_undefined_vars = False
+# by default (as of 1.6), Ansible may display warnings based on the configuration of the
+# system running ansible itself. This may include warnings about 3rd party packages or
+# other conditions that should be resolved if possible.
+# to disable these warnings, set the following value to False:
+#system_warnings = True
+
+# by default (as of 1.4), Ansible may display deprecation warnings for language
+# features that should no longer be used and will be removed in future versions.
+# to disable these warnings, set the following value to False:
+#deprecation_warnings = True
+
# set plugin path directories here, separate with colons
action_plugins = /usr/share/ansible_plugins/action_plugins
callback_plugins = /usr/share/ansible_plugins/callback_plugins
diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py
index f088b76720..a4a1bfdc9c 100644
--- a/lib/ansible/constants.py
+++ b/lib/ansible/constants.py
@@ -150,6 +150,7 @@ ANSIBLE_NOCOWS = get_config(p, DEFAULTS, 'nocows', 'ANSIBLE_NOCO
DISPLAY_SKIPPED_HOSTS = get_config(p, DEFAULTS, 'display_skipped_hosts', 'DISPLAY_SKIPPED_HOSTS', True, boolean=True)
DEFAULT_UNDEFINED_VAR_BEHAVIOR = get_config(p, DEFAULTS, 'error_on_undefined_vars', 'ANSIBLE_ERROR_ON_UNDEFINED_VARS', True, boolean=True)
HOST_KEY_CHECKING = get_config(p, DEFAULTS, 'host_key_checking', 'ANSIBLE_HOST_KEY_CHECKING', True, boolean=True)
+SYSTEM_WARNINGS = get_config(p, DEFAULTS, 'system_warnings', 'ANSIBLE_SYSTEM_WARNINGS', True, boolean=True)
DEPRECATION_WARNINGS = get_config(p, DEFAULTS, 'deprecation_warnings', 'ANSIBLE_DEPRECATION_WARNINGS', True, boolean=True)
# CONNECTION RELATED
diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py
index 3a308d16a3..435da481c4 100644
--- a/lib/ansible/utils/__init__.py
+++ b/lib/ansible/utils/__init__.py
@@ -44,7 +44,6 @@ import getpass
import sys
import textwrap
import json
-import warnings
#import vault
from vault import VaultLib
@@ -83,8 +82,11 @@ try:
import keyczar.errors as key_errors
from keyczar.keys import AesKey
except PowmInsecureWarning:
- display("The version of gmp you have installed has a known issue regarding timing vulnerabilities when used with pycrypto. " + \
- "If possible, you should update it (ie. yum update gmp).", color="purple", stderr=True)
+ system_warning(
+ "The version of gmp you have installed has a known issue regarding " + \
+ "timing vulnerabilities when used with pycrypto. " + \
+ "If possible, you should update it (ie. yum update gmp)."
+ )
warnings.resetwarnings()
warnings.simplefilter("ignore")
import keyczar.errors as key_errors
@@ -1155,6 +1157,10 @@ def warning(msg):
display(new_msg, color='bright purple', stderr=True)
warns[new_msg] = 1
+def system_warning(msg):
+ if C.SYSTEM_WARNINGS:
+ warning(msg)
+
def combine_vars(a, b):
if C.DEFAULT_HASH_BEHAVIOUR == "merge":