From 7158eb489f1817adc01177f9d6d67417883e080b Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Fri, 19 Feb 2016 12:59:58 -0600 Subject: [PATCH 1/2] Add python info to facts --- lib/ansible/module_utils/facts.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index fd5729c7c0..53c4133575 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -166,6 +166,7 @@ class Facts(object): self.get_local_facts() self.get_env_facts() self.get_dns_facts() + self.get_python_facts() def populate(self): return self.facts @@ -782,6 +783,21 @@ class Facts(object): pass return size_total, size_available + def get_python_facts(self): + self.facts['python'] = { + 'version': { + 'major': sys.version_info[0], + 'minor': sys.version_info[1], + 'micro': sys.version_info[2], + 'releaselevel': sys.version_info[3], + 'serial': sys.version_info[4] + }, + 'version_info': list(sys.version_info), + 'executable': sys.executable, + 'type': sys.subversion[0] + } + + class Hardware(Facts): """ This is a generic Hardware subclass of Facts. This should be further From d9a207f24f46d76c3b05650b3e908c161786a2b9 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 23 Feb 2016 11:28:04 -0600 Subject: [PATCH 2/2] Add has_sslcontext fact as well --- lib/ansible/module_utils/facts.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 53c4133575..e698d780ff 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -44,6 +44,15 @@ try: except ImportError: HAVE_SELINUX=False +try: + # Check if we have SSLContext support + from ssl import create_default_context, SSLContext + del create_default_context + del SSLContext + HAS_SSLCONTEXT = True +except ImportError: + HAS_SSLCONTEXT = False + try: import json # Detect python-json which is incompatible and fallback to simplejson in @@ -794,7 +803,8 @@ class Facts(object): }, 'version_info': list(sys.version_info), 'executable': sys.executable, - 'type': sys.subversion[0] + 'type': sys.subversion[0], + 'has_sslcontext': HAS_SSLCONTEXT }