Skip to content

dig + wantlist can return a list with an empty string instead of an empty list #5428

@RomainMou

Description

@RomainMou

Summary

When I use the lookup plugin community.general.dig with wantlist=true and there is no record, the plugin return [""] instead of [].
community.general.dnstxt has the same issue.

Issue Type

Bug Report

Component Name

dig

Ansible Version

ansible [core 2.13.5]
  config file = /home/user/Documents/dev/deployment/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.virtualenvs/tmp-9bc177cc8a2084d/lib/python3.10/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.virtualenvs/tmp-9bc177cc8a2084d/bin/ansible
  python version = 3.10.8 (main, Oct 13 2022, 21:13:48) [GCC 12.2.0]
  jinja version = 3.1.2
  libyaml = True

Community.general Version

# /home/user/.virtualenvs/tmp-9bc177cc8a2084d/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 5.7.0  

# /home/user/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 5.8.0

Configuration

DEFAULT_FILTER_PLUGIN_PATH(/home/user/Documents/dev/deployment/ansible.cfg) = ['/home/user/Documents/dev/deployment/ansible_plugins/filter_plugins']
DEFAULT_TIMEOUT(/home/user/Documents/dev/deployment/ansible.cfg) = 60
DEFAULT_VAULT_PASSWORD_FILE(/home/user/Documents/dev/deployment/ansible.cfg) = /home/user/Documents/dev/deployment/.get-vault-pass.sh

OS / Environment

No response

Steps to Reproduce

- name: "Test lookup"
  hosts: localhost
  gather_facts: false
  tasks:
    - name: "Check version of community.general"
      ansible.builtin.debug:
        msg: "community.general version {{ lookup('community.general.collection_version', 'community.general') }}"

    - name: "There is no NS, so we expect an empty list"
      ansible.builtin.set_fact:
        ns: "{{ lookup('community.general.dig',
                'www.google.com',
                'qtype=NS',
                wantlist=true) }}"

    - name: "Print retrieve NS"
      ansible.builtin.debug:
        var: ns

Expected Results

TASK [Print retrieve NS] ****************************************************************************************************************************************************************************
ok: [localhost] => {
"ns": []
}

Actual Results

PLAY [Test lookup] **********************************************************************************************************************************************************************************

TASK [Check version of community.general] ***********************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "community.general version 5.8.0"
}

TASK [There is NS, so we expect empty result] *******************************************************************************************************************************************************
ok: [localhost]

TASK [Print retrieve NS] ****************************************************************************************************************************************************************************
ok: [localhost] => {
    "ns": [
        ""
    ]
}

PLAY RECAP ******************************************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a buglookuplookup pluginpluginsplugin (any type)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions