/
githubmirror
/
ydb-ansible
Обзор
Документация
Войти
/
githubmirror
/
ydb-ansible
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
plugins/modules/dstool_cmd.py
42 строки
1 KB
Eugene Arbatsky
YDBOPS-13476 Distconf and 2DC (#112)
18 дек 2025, 10:13
Не верифицирован
18 дек 2025, 10:13
47364e8
Код
Авторство
О чём код?
import os from ansible.module_utils.basic import AnsibleModule from ansible_collections.ydb_platform.ydb.plugins.module_utils import drive, cli DOCUMENTATION = r''' name: dstool_cmd plugin_type: module short_description: YDB DSTool command executor description: | Module for running commands with YDB DSTool ''' def main(): argument_spec = dict( cmd=dict(type='str', default='') ) cli.DsTool.add_arguments(argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False) result = {'changed': False} try: ydb_dstool = cli.DsTool.from_module(module) cmd = module.params.get('cmd') rc,stdout,stderr = ydb_dstool(cmd.split(" ")) result['stdout'] = stdout if rc != 0: result['stderr'] = stderr module.fail_json(**result) result['changed'] = True module.exit_json(**result) except Exception as e: result['msg'] = f'unexpected exception: {e}' module.fail_json(**result) if __name__ == '__main__': main()