initial commit: start from basic action plugin
This commit is contained in:
commit
852d425d25
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
*~
|
||||||
|
\#*
|
||||||
|
.#*
|
||||||
|
*.pyc
|
||||||
|
*.bak
|
||||||
|
__pycache__
|
31
wildfly.py
Normal file
31
wildfly.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Make coding more python3-ish, this is required for contributions to Ansible
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
from ansible.plugins.action import ActionBase
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
class ActionModule(ActionBase):
|
||||||
|
def run(self, tmp=None, task_vars=None):
|
||||||
|
super(ActionModule, self).run(tmp, task_vars)
|
||||||
|
module_args = self._task.args.copy()
|
||||||
|
module_return = self._execute_module(module_name='setup',
|
||||||
|
module_args=module_args,
|
||||||
|
task_vars=task_vars, tmp=tmp)
|
||||||
|
ret = dict()
|
||||||
|
remote_date = None
|
||||||
|
if not module_return.get('failed'):
|
||||||
|
for key, value in module_return['ansible_facts'].items():
|
||||||
|
if key == 'ansible_date_time':
|
||||||
|
remote_date = value['iso8601']
|
||||||
|
|
||||||
|
if remote_date:
|
||||||
|
remote_date_obj = datetime.strptime(remote_date, '%Y-%m-%dT%H:%M:%SZ')
|
||||||
|
time_delta = datetime.now() - remote_date_obj
|
||||||
|
ret['delta_seconds'] = time_delta.seconds
|
||||||
|
ret['delta_days'] = time_delta.days
|
||||||
|
ret['delta_microseconds'] = time_delta.microseconds
|
||||||
|
|
||||||
|
return dict(ansible_facts=dict(ret))
|
Loading…
x
Reference in New Issue
Block a user