2022-04-25 22:12:00 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
2022-08-08 14:24:58 +02:00
|
|
|
# Copyright (c) 2022, Alexei Znamensky <russoz@gmail.com>
|
2022-08-05 12:28:29 +02:00
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2022-04-25 22:12:00 +02:00
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
|
2022-06-04 09:13:37 +02:00
|
|
|
|
|
|
|
DOCUMENTATION = ""
|
2022-04-25 22:12:00 +02:00
|
|
|
|
|
|
|
EXAMPLES = ""
|
|
|
|
|
|
|
|
RETURN = ""
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
2022-06-05 18:37:59 +02:00
|
|
|
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt
|
2022-04-25 22:12:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec=dict(
|
|
|
|
arg_formats=dict(type="dict", default={}),
|
|
|
|
arg_order=dict(type="raw", required=True),
|
|
|
|
arg_values=dict(type="dict", default={}),
|
2022-06-04 09:13:37 +02:00
|
|
|
check_mode_skip=dict(type="bool", default=False),
|
2022-04-25 22:12:00 +02:00
|
|
|
aa=dict(type="raw"),
|
|
|
|
),
|
2022-06-04 09:13:37 +02:00
|
|
|
supports_check_mode=True,
|
2022-04-25 22:12:00 +02:00
|
|
|
)
|
|
|
|
p = module.params
|
|
|
|
|
2022-06-04 09:13:37 +02:00
|
|
|
info = None
|
|
|
|
|
2022-04-25 22:12:00 +02:00
|
|
|
arg_formats = {}
|
|
|
|
for arg, fmt_spec in p['arg_formats'].items():
|
|
|
|
func = getattr(fmt, fmt_spec['func'])
|
|
|
|
args = fmt_spec.get("args", [])
|
|
|
|
|
|
|
|
arg_formats[arg] = func(*args)
|
|
|
|
|
|
|
|
runner = CmdRunner(module, ['echo', '--'], arg_formats=arg_formats)
|
|
|
|
|
2022-06-04 09:13:37 +02:00
|
|
|
with runner.context(p['arg_order'], check_mode_skip=p['check_mode_skip']) as ctx:
|
2022-04-25 22:12:00 +02:00
|
|
|
result = ctx.run(**p['arg_values'])
|
|
|
|
info = ctx.run_info
|
2022-06-04 09:13:37 +02:00
|
|
|
check = "check"
|
|
|
|
rc, out, err = result if result is not None else (None, None, None)
|
2022-04-25 22:12:00 +02:00
|
|
|
|
|
|
|
module.exit_json(rc=rc, out=out, err=err, info=info)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|