Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Query TXT records
  • Loading branch information
dmyerscough committed Mar 14, 2014
1 parent 5867646 commit 65add54
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions salt/modules/dig.py
Expand Up @@ -276,6 +276,37 @@ def MX(domain, resolve=False, nameserver=None):

return stdout


def TXT(host, nameserver=None):
'''
Return the TXT record for ``host``.
Always returns a list.
CLI Example:
.. code-block:: bash
salt ns1 dig.TXT google.com
'''
dig = ['dig', '+short', str(host), 'TXT']

if nameserver is not None:
dig.append('@{0}'.format(nameserver))

cmd = __salt__['cmd.run_all'](' '.join(dig))

if cmd['retcode'] != 0:
log.warn(
'dig returned exit code \'{0}\'. Returning empty list as '
'fallback.'.format(
cmd['retcode']
)
)
return []

return [i for i in cmd['stdout'].split('\n')]

# Let lowercase work, since that is the convention for Salt functions
a = A
aaaa = AAAA
Expand Down

0 comments on commit 65add54

Please sign in to comment.