diff --git a/tasks/zones.yml b/tasks/zones.yml index 3e4a287..e619677 100644 --- a/tasks/zones.yml +++ b/tasks/zones.yml @@ -53,7 +53,7 @@ tags: bind - name: Read reverse ipv6 zone hashes - shell: "grep -s \"^; Hash:\" {{ bind_zone_dir }}/{{ (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):-1] }} || true" + shell: "grep -s \"^; Hash:\" {{ bind_zone_dir }}/{{ (item.1 | ansible.netcommon.ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):-1] }} || true" changed_when: false check_mode: false register: reverse_hashes_ipv6_temp @@ -128,12 +128,12 @@ - name: Create reverse IPv6 lookup zone file template: src: reverse_zone_ipv6.j2 - dest: "{{ bind_zone_dir }}/{{ (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):-1] }}" + dest: "{{ bind_zone_dir }}/{{ (item.1 | ansible.netcommon.ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):-1] }}" owner: "{{ bind_owner }}" group: "{{ bind_group }}" mode: "{{ bind_zone_file_mode }}" setype: named_zone_t - validate: "named-checkzone {{ (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):] }} %s" + validate: "named-checkzone {{ (item.1 | ansible.netcommon.ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):] }} %s" become: yes with_subelements: - "{{ bind_zones }}" diff --git a/templates/etc_named.conf.j2 b/templates/etc_named.conf.j2 index c260766..5ef100c 100644 --- a/templates/etc_named.conf.j2 +++ b/templates/etc_named.conf.j2 @@ -180,10 +180,10 @@ zone "{{ ('.'.join(network.replace(network+'.','').split('.')[::-1])) }}.in-addr {% if bind_zone.create_reverse_zones is not defined or bind_zone.create_reverse_zones %} {% for network in bind_zone.ipv6_networks %} -zone "{{ (network | ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int)//2):] }}" IN { +zone "{{ (network | ansible.netcommon.ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int)//2):] }}" IN { {% if _type == 'primary' %} type master; - file "{{ bind_zone_dir }}/{{ (network | ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int)//2):-1] }}"; + file "{{ bind_zone_dir }}/{{ (network | ansible.netcommon.ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int)//2):-1] }}"; notify yes; {% if bind_zone.also_notify is defined %} also-notify { {{ bind_zone.also_notify|join('; ') }}; }; @@ -196,7 +196,7 @@ zone "{{ (network | ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int) {% elif _type == 'secondary' %} type slave; masters { {{ bind_zone.primaries|join('; ') }}; }; - file "{{ bind_secondary_dir }}/{{ (network | ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int)//2):-1] }}"; + file "{{ bind_secondary_dir }}/{{ (network | ansible.netcommon.ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int)//2):-1] }}"; {% elif _type == 'forward' %} type forward; forward only; diff --git a/templates/reverse_zone_ipv6.j2 b/templates/reverse_zone_ipv6.j2 index 9b26382..469c128 100644 --- a/templates/reverse_zone_ipv6.j2 +++ b/templates/reverse_zone_ipv6.j2 @@ -18,7 +18,7 @@ {% set _ = _zone_data.update({'expire': bind_zone_time_to_expire}) %} {% set _ = _zone_data.update({'minimum': bind_zone_minimum_ttl}) %} {% set _ = _zone_data.update({'hosts': item.0.hosts|default([]) | selectattr('ipv6','defined') | selectattr('ipv6','string') | selectattr('ipv6', 'search', '^'+item.1|regex_replace(':\/.*$','')) | list }) %} -{% set _ = _zone_data.update({'revip': (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):] }) %} +{% set _ = _zone_data.update({'revip': (item.1 | ansible.netcommon.ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):] }) %} {# # Compare the zone file hash with the current zone data hash and set serial # accordingly @@ -40,7 +40,7 @@ {{ ansible_managed | comment(decoration='; ') }} $TTL {{ _zone_data['ttl'] }} -$ORIGIN {{ (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):] }} +$ORIGIN {{ (item.1 | ansible.netcommon.ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):] }} {% if _zone_data['mname']|length > 0 %} @ IN SOA {{ _zone_data['mname']|first }}{% if not _zone_data['mname']|first|regex_search('\.$') %}.{{ _zone_data['domain'] }}.{% endif %} {{ _zone_data['rname'] }}. ( @@ -73,17 +73,17 @@ $ORIGIN {{ (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int) {% else %} {% if host.ipv6 is string and host.ipv6.startswith(item.1|regex_replace(':\/.*$','')) %} {% if host.name == '@' %} -{{ host.ipv6 | ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ _zone_data['domain'] }}. +{{ host.ipv6 | ansible.netcommon.ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ _zone_data['domain'] }}. {% else %} -{{ host.ipv6 | ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ host.name }}.{{ _zone_data['domain'] }}. +{{ host.ipv6 | ansible.netcommon.ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ host.name }}.{{ _zone_data['domain'] }}. {% endif %} {% else %} {% for ip in host.ipv6 %} {% if ip.startswith(item.1|regex_replace(':\/.*$','')) %} -{{ ip | ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ _zone_data['domain'] }}. +{{ ip | ansible.netcommon.ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ _zone_data['domain'] }}. {% if host.name == '@' %} {% else %} -{{ ip | ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ host.name }}.{{ _zone_data['domain'] }}. +{{ ip | ansible.netcommon.ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ host.name }}.{{ _zone_data['domain'] }}. {% endif %} {% endif %} {% endfor %} @@ -92,5 +92,5 @@ $ORIGIN {{ (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int) {% endif %} {% endfor %} {% else %} -{{ ansible_default_ipv6.address | ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ ansible_hostname }}.{{ _zone_data['domain'] }}. +{{ ansible_default_ipv6.address | ansible.netcommon.ipaddr('revdns') }}{{ (host.ttl|string).rjust(6) if host.ttl is defined else ''.ljust(6) }} IN PTR {{ ansible_hostname }}.{{ _zone_data['domain'] }}. {% endif %}