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

[FEATURE REQUEST] salt dig module: dig.x #62275

Closed
matthewsaum opened this issue Jul 5, 2022 · 7 comments
Closed

[FEATURE REQUEST] salt dig module: dig.x #62275

matthewsaum opened this issue Jul 5, 2022 · 7 comments
Labels
Execution-Module Feature new functionality including changes to functionality and code refactors, etc.

Comments

@matthewsaum
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I love the use of salt modules, both in my jinja templates and for regular system administration, but I find the ability to do a reverse-lookup of an IP somewhat lacking.

Describe the solution you'd like
The salt module dig has a handful of useful functions already, the most-used being dig.A, so I suggest trying to get dig.x to also work.

Describe alternatives you've considered
I've been running cmd.shell host 1.2.3.4 and other such workarounds, but a module would be great.

Additional context

Please Note
If this feature request would be considered a substantial change or addition, this should go through a SEP process here https://github.com/saltstack/salt-enhancement-proposals, instead of a feature request.

@matthewsaum matthewsaum added Feature new functionality including changes to functionality and code refactors, etc. needs-triage labels Jul 5, 2022
@welcome
Copy link

welcome bot commented Jul 5, 2022

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@matthewsaum
Copy link
Contributor Author

I added a block in a local module in my environment. Just felt it ought to be pushed upward for proper integration.

def X(host, nameserver=None):
    '''
    Return the PTR record for ``host``.

    Always returns a list.

    CLI Example:

    .. code-block:: bash

        salt ns1 dig.X 1.2.3.4
    '''
    dig = ['dig', '+short', '-x', six.text_type(host) ]

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

    cmd = __salt__['cmd.run_all'](dig, python_shell=False)

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

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

@nicholasmhughes
Copy link
Collaborator

@matthewsaum , that's great! Would you be willing to put that functionality into a PR? It would only need a couple of basic unit tests See #61992 for ideas on how to make that happen and feel free to ping me with any additional questions.

@matthewsaum
Copy link
Contributor Author

@nicholasmhughes Happy to try to figure it out. I'll see if I can get it working and get back to you before end of day Friday.

@matthewsaum
Copy link
Contributor Author

Please to report I've got documentation and a local dev environment running. I'll poke it and get a proper test suite run and have a merge request incoming.

@matthewsaum
Copy link
Contributor Author

So I learned a bit more about things while doing that first attempted Pull Request. New PR should be popping up shortly.

@matthewsaum matthewsaum mentioned this issue Jul 9, 2022
3 tasks
@nicholasmhughes
Copy link
Collaborator

Closed by #62314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Execution-Module Feature new functionality including changes to functionality and code refactors, etc.
Projects
None yet
Development

No branches or pull requests

2 participants