
    Vh-                         d dl mZmZmZ eZdZdZdZdZ		 d dl
Zd dlmZ dZ	d d	lmZ d d
lmZ  G d de      Zy# e$ r Y w xY w)    )absolute_importdivisionprint_functiona  
name: dnstxt
author: Jan-Piet Mens (@jpmens) <jpmens(at)gmail.com>
short_description: query a domain(s)'s DNS txt fields
requirements:
  - dns/dns.resolver (python library)
description:
  - Uses a python library to return the DNS TXT record for a domain.
options:
  _terms:
    description: Domain or list of domains to query TXT records from.
    required: true
    type: list
    elements: string
  real_empty:
    description:
      - Return empty result without empty strings, and return empty list instead of V(NXDOMAIN).
      - The default for this option will likely change to V(true) in the future.
    default: false
    type: bool
    version_added: 6.0.0
a  
- name: show txt entry
  ansible.builtin.debug:
    msg: "{{lookup('community.general.dnstxt', ['test.example.com'])}}"

- name: iterate over txt entries
  ansible.builtin.debug:
    msg: "{{item}}"
  with_community.general.dnstxt:
    - 'test.example.com'
    - 'other.example.com'
    - 'last.example.com'

- name: iterate of a comma delimited DNS TXT entry
  ansible.builtin.debug:
    msg: "{{item}}"
  with_community.general.dnstxt: "{{lookup('community.general.dnstxt', ['test.example.com']).split(',')}}"
zQ
_list:
  description:
    - Values returned by the DNS TXT record.
  type: list
FN)DNSExceptionT)AnsibleError)
LookupBasec                       e Zd ZddZy)LookupModuleNc                    | j                  ||       t        du rt        d      | j                  d      }g }|D ]  }|j	                         d   }g }	 t
        j                  j                  |d      }	|	D ]&  }
|
j                         }|j                  |dd        ( 	 |j                  d
j                  |              |S # t
        j                  j                  $ r	 |rY d	}Y It
        j                  j                  $ r	 |rY d
}Y mt
        j                  j                  $ r	 |rY d
}Y t        $ r}t        d|       d }~ww xY w)N)var_optionsdirectFz:Can't LOOKUP(dnstxt): module dns.resolver is not installed
real_emptyr   TXT   NXDOMAIN z!dns.resolver unhandled exception )set_optionsHAVE_DNSr   
get_optionsplitdnsresolverqueryto_textappendr   TimeoutNoAnswerr   join)selfterms	variableskwargsr   rettermdomainstringanswersrdatases                k/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/lookup/dnstxt.pyrunzLookupModule.runO   sB   Yv>u[\\__\2
 	(DZZ\!_FFL,,,,VU;$ +EAMM!Ab'*+& JJrwwv'1	(4 
# <<(( $#<<'' <<((  L"%Fqc#JKKLs=   ACE&E*E
EE.E2E:EE)N)__name__
__module____qualname__r-        r,   r
   r
   M   s    #r2   r
   )
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESRETURNr   dns.resolverr   dns.exceptionr   ImportErroransible.errorsr   ansible.plugins.lookupr   r
   r1   r2   r,   <module>r>      sg    C B.&
 	*H ( -%: %  		s   : AA