DNS query plugin advice request

I've been working on a lookup plugin for getting DNS records, and have
an issue I haven't been able to resolve satisfactorily. I thought maybe
folks on this list might have ideas.

So the plugin is designed to accept query for any type of DNS record,
like so:

    $DNSQ(@server record-name.example.org CNAME)

Now there can of course be multiple records for many types of DNS
entries (think round-robin A records, for example), and I'm not sure how
best to handle that situation in the plugin.

It seems easiest to work with the results when they come in the form of
a string, as it makes conditionals and interpolation simpler, but
a string of multiple records concatenated is harder to work with than,
say, a list.

Any thoughts?

I've been working on a lookup plugin for getting DNS records

Nice. Care to say which Python module you'll be using? I'm
assuming/hoping it's dnspython because that's what my dnsupdate module
uses :slight_smile:

So the plugin is designed to accept query for any type of DNS record,
like so:

    $DNSQ(@server record-name.example.org CNAME)

Commas missing?

Now there can of course be multiple records for many types of DNS
entries (think round-robin A records, for example), and I'm not sure how
best to handle that situation in the plugin.

It seems easiest to work with the results when they come in the form of
a string, as it makes conditionals and interpolation simpler, but
a string of multiple records concatenated is harder to work with than,
say, a list.

I haven't actually tested this, but returning a JSON object which
Ansible could 'register' and process as complex data [1] would be my
preferred method.

        -JP

[1] http://ansible.cc/docs/playbooks2.html#accessing-complex-variable-data

Excerpts from Jan-Piet Mens's message of 2013-03-25 14:36:59 -0400:

Nice. Care to say which Python module you'll be using? I'm
assuming/hoping it's dnspython because that's what my dnsupdate module
uses :slight_smile:

Yeah, dnspython. I did see your dnsupdate module.

Commas missing?

I'll probably make them optional.

I haven't actually tested this, but returning a JSON object which
Ansible could 'register' and process as complex data [1] would be my
preferred method.

In that case, a module intended for use as a 'local_action' would be
required, no?

In order to use a lookup plugin with register, I'd need something like:

    - shell: echo "$DNSQ(blahfooblah)"
      register: itsavar

...which seems a bit ugly to me. Can you return complex data from
a lookup plugin? Even if you can, it seems a bit iffy to me.

Any thoughts on the module vs. lookup plugin issue?

We have a 'network' module in the ansible-provisioning repository with the aim of querying an IP address or hostname against DNS and returning information that is generally useful. (Depending on the options you only do one name lookup, or do a reverse namelookup as well, the module also sets the FQDN and domain names)

A second (optional) feature of the network module is to match an IP-address against a yaml file with network-ranges, and the module will then set the variables related to the network-range it matches against. This is useful to list vlan's with information related to that range (e.g. DNS information, DNS search list, NTP, gateway, netmask, datacenter, environment, vlan ID, and everything that is useful to you).

This module can be used to automagically and correctly configure a network interface without having to rely on manually entered input (and only requires the most basic info, which is the IP address itself).

You can find the module from:

   https://github.com/ansible-provisioning/ansible-provisioning

It used to be called 'network', but was renamed 'network_facts' when we standardized on the '_facts' postfix for modules that only add facts.