ansibledig

Issue with ansible dig Argument 'text' has incorrect type (expected str, got AnsibleUnicode)


I try to do a dig of an hostname with ansible with this playbook:

---                                                                                                                                                                                                                                                                                           
- hosts: localhost                                                                                                                           
  tasks:                                                                                                                                           
  - name: Simple A record (IPV4 address) lookup                                                                                     
    debug: msg="{{ lookup('dig', 'www.google.com.')}}" 

To have the same configuration and behavior on several laptop I'm running ansible in an alpine docker container.
I've installed python3 (v3.11.6) py3-dnspython net-tools bind-tools bind-libs and ansible (v2.14.5). When I run the command: ansible-playbook -i localhost test.yml I've got the following error:

TASK [Simple A record (IPV4 address) lookup] ****************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'dig'. 
Error was a <class 'ansible.errors.AnsibleError'>, original message: dns lookup illegal CLASS: Argument 'text' has incorrect type (expected str, got AnsibleUnicode). 
dns lookup illegal CLASS: Argument 'text' has incorrect type (expected str, got AnsibleUnicode)"}

Do you know what I'm doing wrong ?

I've try to install dnspython with pip without success


Solution

  • I've finally found a solution, apparently as β.εηοιτ.βε said it was an incompatibility between ansible community general and python. I've downgrade python version to 3.9.18 and use alpine 3.15 image. Now it works