Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dnssrv lookup module. #58806

Open
wants to merge 6 commits into
base: devel
from

Conversation

Projects
None yet
3 participants
@rmkraus
Copy link
Contributor

commented Jul 8, 2019

SUMMARY

This adds a new lookup module, dnssrv. It was modeled after the dnstxt lookup module, but for SRV records. It parses the results and returns them grouped and sorted per the RFC 2782 spec.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

plugin/lookup/dnssrv

ADDITIONAL INFORMATION

Formerly, this same action could be mostly replicated using the dig lkp module. That code would look like this:

record: '{{ ["target", "port"] | map("extract", lookup("dig", "_test._tcp.example.com/SRV", "flat=0", wantlist=True).0) | map("regex_replace", "\.$", "") | join(":") }}'

With the dnssrv lookup module, it now looks like this:

record: '{{ lookup("dnssrv", "_test._tcp.example.com").0.0.target }}'

This lookup plugin also extends what is reasonably possible with the dig plugin as everything is sorted and provides the provided weighting information from the DNS records.

rmkraus added some commits Jul 8, 2019

Created dnssrv lookup plugin.
This lookup plugin operates in a very similar way as the dnstxt lookup
plugin, except it will lookup SRV records from DNS. It then parses the
records and returns them sorted and grouped per the RFC 2782 spec.

Signed-off-by: Ryan Kraus <rmkraus@gmail.com>
Added tests for dnssrv lookup module.
1) Moved the code for the actual DNS query out of the run method in the
   LookupModule class. This was done so it could be mocked in tests.
2) Added two tests. One to test a good lookup and one to test a bad lookup.

Signed-off-by: Ryan Kraus <rmkraus@gmail.com>
Fixed typo in dnssrv documentation.
Signed-off-by: Ryan Kraus <rmkraus@gmail.com>
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2019

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/plugins/lookup/dnssrv.py:69:4: blacklisted-name Black listed name "_"

The test ansible-test sanity --test pep8 [explain] failed with 11 errors:

lib/ansible/plugins/lookup/dnssrv.py:69:45: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:39:34: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:39:37: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:40:34: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:40:37: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:41:34: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:41:37: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:42:34: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:42:37: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:43:34: E226 missing whitespace around arithmetic operator
test/units/plugins/lookup/test_dnssrv.py:43:37: E226 missing whitespace around arithmetic operator

click here for bot help

@ansibot ansibot added needs_revision and removed core_review labels Jul 8, 2019

Resolved testing issues with dnssrv lookup plugin and test.
Signed-off-by: Ryan Kraus <rmkraus@gmail.com>
Added dnspython dependency to unit tests.
This dependency is needed to test dnssrv.

Signed-off-by: Ryan Kraus <rmkraus@gmail.com>
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2019

@ansibot ansibot added the test label Jul 8, 2019

@rmkraus

This comment has been minimized.

Copy link
Contributor Author

commented Jul 8, 2019

Sorry for the multiple commits. This is my first time playing with the Ansible unit tests. It looks like everything is passing now except two tests that failed because of unrelated web issues. Should be ready to review! Thanks.

@bcoca bcoca removed the needs_triage label Jul 11, 2019

@ansibot ansibot added the stale_ci label Jul 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.