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

Cannot update "NS" types entries from Bind9 managed DNS zone #4657

Closed
1 task done
Simon-TheUser opened this issue May 9, 2022 · 5 comments · Fixed by #5377
Closed
1 task done

Cannot update "NS" types entries from Bind9 managed DNS zone #4657

Simon-TheUser opened this issue May 9, 2022 · 5 comments · Fixed by #5377
Labels
bug This issue/PR relates to a bug has_pr module module net_tools plugins plugin (any type)

Comments

@Simon-TheUser
Copy link
Contributor

Summary

When running a nsupdate task where the type: "NS" is used, Ansible reports a successful change.

Unfortunately, Bind9 will silently ignore the deletes statement for NS type for a zone and the Ansible change does not work.

Issue Type

Bug Report

Component Name

nsupdate

Ansible Version

$ ansible --version
ansible [core 2.12.5]
  config file = None
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/github.Simon-TheUser.community.general/venv/lib/python3.8/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/github.Simon-TheUser.community.general/venv/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 4.8.0  

Configuration

$ ansible-config dump --only-changed

OS / Environment

The changes are made against a Bind9.18 DNS Server

Steps to Reproduce

Before running the test, gather the list of NS entries for a DNS zone.

$ dig NS lab @192.168.1.2 +short
ns6.lab.
ns3.lab.
ns2.lab.
ns4.lab.

Create a task that does not include the ns3.lab. entry and execute it:

  tasks:
    - name: New NS entries
      set_fact:
        ns_list:
          - 'ns2.lab.'
          - 'ns4.lab.'
          - 'ns6.lab.'

    - name: Update NS entries
      community.general.nsupdate:
        key_name: '{{ rndc_key_name }}'
        key_secret: '{{ rndc_key }}'
        key_algorithm: 'hmac-sha256'
        server: "192.168.1.2"
        zone: "lab."
        record: "lab."
        value: "{{ ns_list }}"
        type: "NS"
$ ansible-playbook test_NS_nsupdate.yml 

PLAY [Test for Dynamic DNS updates of NS entries with Bind9] **********************************************************************************************************************************************************************

TASK [New NS entries] *************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Update NS entries] **********************************************************************************************************************************************************************************************************
changed: [localhost]

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

Expected Results

After executing the task, I would expect the new list of NS records to only contain 3 items:

$ dig NS lab @192.168.1.2 +short
ns6.lab.
ns2.lab.
ns4.lab.

Actual Results

Running the domain query shows that ns3.lab. is still present as a NS entry:

$ dig NS lab @192.168.1.2 +short
ns6.lab.
ns3.lab.
ns2.lab.
ns4.lab.

Inside the Bind9 logs, you can see that the delete request for NS records is ignored:

09-May-2022 18:00:50.352 client @0x7fe7dd1f9568 192.168.1.3#45458/key rndc_ddns_ansible: updating zone 'lab/IN': attempt to delete all SOA or NS records ignored

Bind9 source code reference: https://gitlab.isc.org/isc-projects/bind9/-/blob/v9_18/lib/ns/update.c#L3304

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module net_tools plugins plugin (any type) labels May 9, 2022
Simon-TheUser added a commit to Simon-TheUser/community.general that referenced this issue May 9, 2022
@Simon-TheUser
Copy link
Contributor Author

I have successfully modified the nsupdate.py script with the following changes for my environment:
Simon-TheUser@ceb8131

Feel free to grab the changes or I can create a pull request if that is your preferred approach.

@felixfontein
Copy link
Collaborator

I'm not sure whether someone is actively maintaining this module, so creating a PR probably increases chances a lot that this fix will end up in this collection :)

@Simon-TheUser
Copy link
Contributor Author

I will submit a PR after I complete my infrastructure changes. It will give me a chance to properly test my changes against bind9.18.

@Simon-TheUser Simon-TheUser changed the title Cannot remove "NS" types entries from Bind9 managed DNS zone Cannot update "NS" types entries from Bind9 managed DNS zone Oct 17, 2022
Simon-TheUser added a commit to Simon-TheUser/community.general that referenced this issue Oct 25, 2022
felixfontein added a commit that referenced this issue Nov 2, 2022
* Insert new entries before deleting old ones.
resolves #4657

* Slight wording changes.

* lint fix

* Address lint

* Added changelog
Fixed lint

* More linting

* Update changelogs/fragments/5377-nsupdate-ns-records-with-bind.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
patchback bot pushed a commit that referenced this issue Nov 2, 2022
* Insert new entries before deleting old ones.
resolves #4657

* Slight wording changes.

* lint fix

* Address lint

* Added changelog
Fixed lint

* More linting

* Update changelogs/fragments/5377-nsupdate-ns-records-with-bind.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 5cb9a9e)
felixfontein pushed a commit that referenced this issue Nov 2, 2022
* Insert new entries before deleting old ones.
resolves #4657

* Slight wording changes.

* lint fix

* Address lint

* Added changelog
Fixed lint

* More linting

* Update changelogs/fragments/5377-nsupdate-ns-records-with-bind.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 5cb9a9e)

Co-authored-by: Simon-TheUser <35318753+Simon-TheUser@users.noreply.github.com>
rekup pushed a commit to rekup/community.general that referenced this issue Nov 3, 2022
* Insert new entries before deleting old ones.
resolves ansible-collections#4657

* Slight wording changes.

* lint fix

* Address lint

* Added changelog
Fixed lint

* More linting

* Update changelogs/fragments/5377-nsupdate-ns-records-with-bind.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
russoz pushed a commit to russoz-ansible/community.general that referenced this issue Nov 5, 2022
* Insert new entries before deleting old ones.
resolves ansible-collections#4657

* Slight wording changes.

* lint fix

* Address lint

* Added changelog
Fixed lint

* More linting

* Update changelogs/fragments/5377-nsupdate-ns-records-with-bind.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
bratwurzt pushed a commit to bratwurzt/community.general that referenced this issue Nov 7, 2022
* Insert new entries before deleting old ones.
resolves ansible-collections#4657

* Slight wording changes.

* lint fix

* Address lint

* Added changelog
Fixed lint

* More linting

* Update changelogs/fragments/5377-nsupdate-ns-records-with-bind.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
bratwurzt pushed a commit to bratwurzt/community.general that referenced this issue Nov 7, 2022
* Insert new entries before deleting old ones.
resolves ansible-collections#4657

* Slight wording changes.

* lint fix

* Address lint

* Added changelog
Fixed lint

* More linting

* Update changelogs/fragments/5377-nsupdate-ns-records-with-bind.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This was referenced Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module net_tools plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants