1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #2241 from tonk/devel

Added dat and time facts to setup
This commit is contained in:
Michael DeHaan 2013-02-28 12:43:26 -08:00
commit 60da7591c2

View file

@ -26,6 +26,7 @@ import platform
import re
import socket
import struct
import datetime
DOCUMENTATION = '''
---
@ -117,6 +118,7 @@ class Facts(object):
self.get_selinux_facts()
self.get_pkg_mgr_facts()
self.get_lsb_facts()
self.get_date_time_facts()
def populate(self):
return self.facts
@ -289,6 +291,22 @@ class Facts(object):
except OSError, e:
self.facts['selinux']['type'] = 'unknown'
def get_date_time_facts(self):
self.facts['date_time'] = {}
now = datetime.datetime.now()
self.facts['date_time']['year'] = now.strftime('%Y')
self.facts['date_time']['month'] = now.strftime('%m')
self.facts['date_time']['day'] = now.strftime('%d')
self.facts['date_time']['hour'] = now.strftime('%H')
self.facts['date_time']['minute'] = now.strftime('%M')
self.facts['date_time']['second'] = now.strftime('%S')
self.facts['date_time']['epoch'] = now.strftime('%s')
self.facts['date_time']['date'] = now.strftime('%Y-%m-%d')
self.facts['date_time']['time'] = now.strftime('%H:%M:%S')
class Hardware(Facts):
"""
This is a generic Hardware subclass of Facts. This should be further