ansible-role-yedit icon indicating copy to clipboard operation
ansible-role-yedit copied to clipboard

python exception while running yedit

Open dmitrym0 opened this issue 4 years ago • 1 comments

Hello everyone,

I have a simple yml:

- hosts: localhost
  roles:
  - roles/kwoodson.yedit
  tasks:
  - name: manage yaml files
    yedit:
      src: ~/workspace/docker-machines/test/docker-compose.yml
      key: services.atb.image
      value:
        wakka

However it fails with

module 'yaml' has no attribute 'RoundTripDumper'

Here's the full stack trace:

fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "/Users/dmitry/.ansible/tmp/ansible-tmp-1566064416.420654-155937174493441/AnsiballZ_yedit.py:18: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses\n  import imp\nTraceback (most recent call last):\n  File \"/var/folders/l7/y1c6vkdx02l2mrw0_z90ggcr0000gn/T/ansible_yedit_payload_5wbjyf6s/__main__.py\", line 444, in write\nAttributeError: module 'yaml' has no attribute 'RoundTripDumper'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/Users/dmitry/.ansible/tmp/ansible-tmp-1566064416.420654-155937174493441/AnsiballZ_yedit.py\", line 114, in <module>\n    _ansiballz_main()\n  File \"/Users/dmitry/.ansible/tmp/ansible-tmp-1566064416.420654-155937174493441/AnsiballZ_yedit.py\", line 106, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/dmitry/.ansible/tmp/ansible-tmp-1566064416.420654-155937174493441/AnsiballZ_yedit.py\", line 49, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/usr/local/Cellar/ansible/2.8.4/libexec/lib/python3.7/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n  File \"/usr/local/Cellar/ansible/2.8.4/libexec/lib/python3.7/imp.py\", line 169, in load_source\n    module = _exec(spec, sys.modules[name])\n  File \"<frozen importlib._bootstrap>\", line 630, in _exec\n  File \"<frozen importlib._bootstrap_external>\", line 728, in exec_module\n  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n  File \"/var/folders/l7/y1c6vkdx02l2mrw0_z90ggcr0000gn/T/ansible_yedit_payload_5wbjyf6s/__main__.py\", line 969, in <module>\n  File \"/var/folders/l7/y1c6vkdx02l2mrw0_z90ggcr0000gn/T/ansible_yedit_payload_5wbjyf6s/__main__.py\", line 961, in main\n  File \"/var/folders/l7/y1c6vkdx02l2mrw0_z90ggcr0000gn/T/ansible_yedit_payload_5wbjyf6s/__main__.py\", line 893, in run_ansible\n  File \"/var/folders/l7/y1c6vkdx02l2mrw0_z90ggcr0000gn/T/ansible_yedit_payload_5wbjyf6s/__main__.py\", line 446, in write\n  File \"/var/folders/l7/y1c6vkdx02l2mrw0_z90ggcr0000gn/T/ansible_yedit_payload_5wbjyf6s/__main__.py\", line 408, in _write\nFileNotFoundError: [Errno 2] No such file or directory: '~/workspace/docker-machines/test/docker-compose.yml.yedit'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

However I do believe I have the latest Yaml module:

~/w/a/docker ❯❯❯ python3.7                                                                                                                                                                                                    master ◼
Python 3.7.4 (default, Jul  9 2019, 18:13:23)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'5.1.2'

This is on:

  • MacOS 10.14
  • Ansible 2.8.4

dmitrym0 avatar Aug 17 '19 17:08 dmitrym0

I'm seeing this exact same error. Were you able to get it resolved @dmitrym0?

idolize avatar Sep 21 '23 19:09 idolize