On a Red Hat 8.3 machine I try to use this ansible code:
JavaScript
x
3
1
- debug:
2
msg: "{{ lookup('dig', 'localhost') }}"
3
But I get an error:
JavaScript
1
3
1
TASK*****************************************
2
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"}
3
I think maybe the lookup('dig')
doesn’t search in the right place…
However I think I do in fact have dnspython
installed:
JavaScript
1
3
1
pip3 install dnspython --user
2
Requirement already satisfied: dnspython in /home/user/.local/lib/python3.6/site-packages
3
More info:
JavaScript
1
4
1
ansible --version
2
ansible [core 2.12.7]
3
python version = 3.8.3
4
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.