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

Create forward lookup zone file: AnsibleUndefinedVariable: 'dict object' has no attribute 'serial' #183

Open
ruan-dt opened this issue Mar 22, 2022 · 5 comments

Comments

@ruan-dt
Copy link

ruan-dt commented Mar 22, 2022

Short error output:

TASK [bertvv.bind : Create forward lookup zone file] ***************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 'serial'
failed: [hostname] (item=domain.name) => {"ansible_loop_var": "item", "changed": false, "item": {"create_reverse_zones": true, "hosts": [{"aliases": ["a1", "a2", "a3"], "ip": "172.20.8.1", "name": "gateway"}, {"aliases": ["b1"], "name": "somewhere.else."}], "name": "domain.name", "name_servers": ["gateway.domain.name."], "primaries": ["172.20.8.1"], "type": "primary"}, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'serial'"}

Running with -vvv didn't obviously turn up anything more useful, but I can add that output if needs be.

Is this me doing something wrong? Having only been using ansible for a few weeks, and lacking supervision, I can't really tell myself.

@blofeldthefish
Copy link
Collaborator

Hi @ruan-dt

Can you provide the playbook you were using with this role, and it will provide more insight as to what your particular issue is.

We can then look at closer....

@ruan-dt
Copy link
Author

ruan-dt commented Apr 25, 2022

@blofeldthefish so, finally having a little time to get back to this again:

  • the target machines are running ubuntu 22.04
  • tested on two different controllers, one running ubuntu 18.04 lts and one running ubuntu 20.04 lts
  • the playbook completes absolutely fine if only one host is targeted.
  • where two hosts are targeted, it completes only for the first host, with the second host showing the has no attribute 'serial' error.

Minimal host file:

host0 field_subnet="172.20.4.0/22"
host1 field_subnet="172.20.8.0/22"

Minimal playbook:

- name: configure hosts
  hosts:
   - host0
   - host1

  vars:
    field_ip: "{{ field_subnet | ansible.netcommon.ipaddr('net') | ansible.netcommon.ipaddr('1') | ansible.netcommon.ipaddr('address') }}"

  roles:
    - role: bertvv.bind
      become: yes

      # if this is missing, the version of bind on ubuntu 22.04 will raise a grumpy 
      # "option 'dnssec-enable' no longer exists" error.
      bind_dnssec_enable: false

      bind_zones:
        - name: "{{ site_name }}"
          type: primary
          primaries:
            - "{{ field_ip }}"
          name_servers:
            - "gateway."
          hosts:
            - name: gateway
              ip: "{{ field_ip }}"

@patrickstump
Copy link

patrickstump commented May 1, 2022

Can confirm this issue. Not sure why, but it works fine on the first server in the group, but not for the following servers.

For example is hosts: group_name vs hosts: server.domain.name.
Originally i thought the issue was that the serial is only calculated as a run_once at tasks/main.yml line 78.

- name: Create serial, based on UTC UNIX time
  command: date -u +%s
  register: timestamp
  changed_when: false
  run_once: true
  check_mode: false
  tags: bind

However, I am not sure now. I tried modifying the serial and removing the run once and it kept happening.

@patrickstump
Copy link

Ok. Have it working.
The issue appears to be not only that timestamp was created for only one host. It could actually deal with that in the zone template.

The main issue is that the hash'es for the zone files were not being calculated on any other host after the first one. Which causes the issue in the zone template.
My workaround atm is to change all the zone hash tasks in tasks/zones.yml with run once to false. And it works fine.

Not sure how this will affect non primary nameservers, as I am not running them that way.

@chrisisbeef
Copy link

Is there a fix for this issue short of forking the repository and getting rid of run_once on those tasks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants