On a Red Hat 8.3 machine I try to use this ansible code:
- debug:
msg: "{{ lookup('dig', 'localhost') }}"
But I get an error:
TASK*****************************************
fatal: [demo.example.com]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'dig'. Error was a <class 'ansible.errors.AnsibleError'>, original message: The dig lookup requires the python 'dnspython' library and it is not installed"}
I think maybe the lookup('dig') doesn’t search in the right place…
However I think I do in fact have dnspython installed:
pip3 install dnspython --user Requirement already satisfied: dnspython in /home/user/.local/lib/python3.6/site-packages
More info:
ansible --version ansible [core 2.12.7] python version = 3.8.3
Advertisement
Answer
Converting comment to answer.
When you use the pip3 command it references the Python 3.6 version you have installed: /home/user/.local/lib/python3.6/site-packages as you can see it says python3.6 and not 3.8. To install the module in 3.8, try to use pip3.8 instead.