mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #14586 from sivel/python-facts
Add python info to facts
This commit is contained in:
commit
27a55d3f33
1 changed files with 26 additions and 0 deletions
|
@ -44,6 +44,15 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAVE_SELINUX=False
|
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:
|
try:
|
||||||
import json
|
import json
|
||||||
# Detect python-json which is incompatible and fallback to simplejson in
|
# Detect python-json which is incompatible and fallback to simplejson in
|
||||||
|
@ -166,6 +175,7 @@ class Facts(object):
|
||||||
self.get_local_facts()
|
self.get_local_facts()
|
||||||
self.get_env_facts()
|
self.get_env_facts()
|
||||||
self.get_dns_facts()
|
self.get_dns_facts()
|
||||||
|
self.get_python_facts()
|
||||||
|
|
||||||
def populate(self):
|
def populate(self):
|
||||||
return self.facts
|
return self.facts
|
||||||
|
@ -782,6 +792,22 @@ class Facts(object):
|
||||||
pass
|
pass
|
||||||
return size_total, size_available
|
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],
|
||||||
|
'has_sslcontext': HAS_SSLCONTEXT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Hardware(Facts):
|
class Hardware(Facts):
|
||||||
"""
|
"""
|
||||||
This is a generic Hardware subclass of Facts. This should be further
|
This is a generic Hardware subclass of Facts. This should be further
|
||||||
|
|
Loading…
Reference in a new issue