Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yedit.py uses deprecated yaml.load and yaml.safe_load from ruamel.yaml #496

Closed
honibis opened this issue Nov 7, 2023 · 7 comments
Closed
Assignees

Comments

@honibis
Copy link

honibis commented Nov 7, 2023

Just installed latest version with latest python and came across deprecation error. ruamel.yaml no longer exposes load and safe_load methods.

in yedit.py i commented 3 lines from line 189 to disable ruamel.yaml and it worked. I dont know about these subjects but still might be useful for people who dont use python, or you might fix it for better.

# try:
#     import     as yaml  # noqa: F401
# except ImportError:
import yaml  # noqa: F401

@vitabaks
Copy link
Owner

vitabaks commented Nov 7, 2023

Thank you @honibis for reporting the problem.

could you point out the complete error?

If possible, try the latest available version of the yedit module - https://github.com/kwoodson/ansible-role-yedit/blob/master/library/yedit.py
maybe we just need to update the module.

It would also be nice to report a problem in the repository of the module yedit project.

@honibis
Copy link
Author

honibis commented Nov 7, 2023

Just reported to yedit too, guess its not quite actively maintained since no-one answered the question "still maintained" asked 3 weeks ago.

This is the error output from playbook:

/tmp/ansible_yedit_payload_bb814zlq/ansible_yedit_payload.zip/ansible/modules/yedit.py", line 495
fatal: [....]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_yedit_payload_bb814zlq/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 493, in load\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1085, in load\n    error_deprecation('load', 'load', arg=_error_dep_arg, comment=_error_dep_comment)\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1039, in error_deprecation\n    raise AttributeError(s, name=None)\nAttributeError: \n\"load()\" has been removed, use\n\n  yaml = YAML(typ='rt')\n  yaml.load(...)\n\nand register any classes that you use, or check the tag attribute on the loaded data,\ninstead of file \"/tmp/ansible_yedit_payload_bb814zlq/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 493\n\n\n\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 99, in _ansiballz_main\n  File \"<stdin>\", line 47, in invoke_module\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_yedit_payload_bb814zlq/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 967, in <module>\n  File \"/tmp/ansible_yedit_payload_bb814zlq/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 959, in main\n  File \"/tmp/ansible_yedit_payload_bb814zlq/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 812, in run_ansible\n  File \"/tmp/ansible_yedit_payload_bb814zlq/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 495, in load\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1105, in safe_load\n    error_deprecation('safe_load', 'load', arg=\"typ='safe', pure=True\")\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1039, in error_deprecation\n    raise AttributeError(s, name=None)\nAttributeError: \n\"safe_load()\" has been removed, use\n\n  yaml = YAML(typ='safe', pure=True)\n  yaml.load(...)\n\ninstead of file \"/tmp/ansible_yedit_payload_bb814zlq/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 495\n\n\n\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: instead of file "/tmp/ansible_yedit_payload_4hu8eoir/ansible_yedit_payload.zip/ansible/modules/yedit.py", line 495
fatal: [....]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_yedit_payload_4hu8eoir/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 493, in load\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1085, in load\n    error_deprecation('load', 'load', arg=_error_dep_arg, comment=_error_dep_comment)\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1039, in error_deprecation\n    raise AttributeError(s, name=None)\nAttributeError: \n\"load()\" has been removed, use\n\n  yaml = YAML(typ='rt')\n  yaml.load(...)\n\nand register any classes that you use, or check the tag attribute on the loaded data,\ninstead of file \"/tmp/ansible_yedit_payload_4hu8eoir/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 493\n\n\n\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 99, in _ansiballz_main\n  File \"<stdin>\", line 47, in invoke_module\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_yedit_payload_4hu8eoir/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 967, in <module>\n  File \"/tmp/ansible_yedit_payload_4hu8eoir/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 959, in main\n  File \"/tmp/ansible_yedit_payload_4hu8eoir/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 812, in run_ansible\n  File \"/tmp/ansible_yedit_payload_4hu8eoir/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 495, in load\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1105, in safe_load\n    error_deprecation('safe_load', 'load', arg=\"typ='safe', pure=True\")\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1039, in error_deprecation\n    raise AttributeError(s, name=None)\nAttributeError: \n\"safe_load()\" has been removed, use\n\n  yaml = YAML(typ='safe', pure=True)\n  yaml.load(...)\n\ninstead of file \"/tmp/ansible_yedit_payload_4hu8eoir/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 495\n\n\n\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: instead of file "/tmp/ansible_yedit_payload_97zxk_ep/ansible_yedit_payload.zip/ansible/modules/yedit.py", line 495
fatal: [....]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_yedit_payload_97zxk_ep/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 493, in load\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1085, in load\n    error_deprecation('load', 'load', arg=_error_dep_arg, comment=_error_dep_comment)\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1039, in error_deprecation\n    raise AttributeError(s, name=None)\nAttributeError: \n\"load()\" has been removed, use\n\n  yaml = YAML(typ='rt')\n  yaml.load(...)\n\nand register any classes that you use, or check the tag attribute on the loaded data,\ninstead of file \"/tmp/ansible_yedit_payload_97zxk_ep/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 493\n\n\n\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 99, in _ansiballz_main\n  File \"<stdin>\", line 47, in invoke_module\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_yedit_payload_97zxk_ep/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 967, in <module>\n  File \"/tmp/ansible_yedit_payload_97zxk_ep/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 959, in main\n  File \"/tmp/ansible_yedit_payload_97zxk_ep/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 812, in run_ansible\n  File \"/tmp/ansible_yedit_payload_97zxk_ep/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 495, in load\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1105, in safe_load\n    error_deprecation('safe_load', 'load', arg=\"typ='safe', pure=True\")\n  File \"/usr/local/lib/python3.10/dist-packages/ruamel/yaml/main.py\", line 1039, in error_deprecation\n    raise AttributeError(s, name=None)\nAttributeError: \n\"safe_load()\" has been removed, use\n\n  yaml = YAML(typ='safe', pure=True)\n  yaml.load(...)\n\ninstead of file \"/tmp/ansible_yedit_payload_97zxk_ep/ansible_yedit_payload.zip/ansible/modules/yedit.py\", line 495\n\n\n\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

@vitabaks
Copy link
Owner

vitabaks commented Nov 7, 2023

Thanks! I think it's worth waiting for a response.

kwoodson/ansible-role-yedit#101

@vitabaks
Copy link
Owner

vitabaks commented Nov 7, 2023

@honibis Feel free to create a PR.

@honibis
Copy link
Author

honibis commented Nov 7, 2023

@honibis Feel free to create a PR.

kwoodson/ansible-role-yedit#102

@honibis honibis closed this as completed Nov 7, 2023
@vitabaks
Copy link
Owner

vitabaks commented Nov 8, 2023

I suggest leaving the issue open until the issue is fully resolved in the postgresql_cluster project.

I see the following options:

  1. Test the use of the yedit module without using ruamel.yaml (apply the fix proposed by @honibis)
  2. Update the module after fixing the problem in the ansible-role-edit project repository
  3. Refuse to use the yedit module (undesirable).

@vitabaks
Copy link
Owner

Fixed #529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@honibis @vitabaks and others