ansible-role-yedit
ansible-role-yedit copied to clipboard
Error: ImportError: No module named yaml
Using Ubuntu 18.04 I get the following error:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named yaml
fatal: [my-host]: FAILED! => changed=false
module_stderr: |-
Traceback (most recent call last):
File "<stdin>", line 114, in <module>
File "<stdin>", line 106, in _ansiballz_main
File "<stdin>", line 49, in invoke_module
File "/tmp/ansible_yedit_payload_fkAMVf/__main__.py", line 191, in <module>
ImportError: No module named yaml
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
I already tried various variants of pip install pyaml
, (python2, python3, earlier version) but to no success. Any ideas?
Note: this happens only with python2
I guess the package needed might be ruamel.yaml
. But tried it no help too.
Hey, I had the same problem.
Installing the package python-yaml
did it for me.
You can do this by running apt install python-yaml
on the managed host or by creating an ansible task:
- name: ensure python-yaml is installed
package:
name: python-yaml
state: present
I had this issue in python3 using pyenv virtual environments on Macos. It seems like the correct python interpreter was not discovered. Fixed by setting the ANSIBLE_PYTHON_INTERPRETER environment variable as follows.
export ANSIBLE_PYTHON_INTERPRETER="$(which python)"