mirror of
https://github.com/dredx/prole.git
synced 2026-09-27 23:14:31 +00:00
30 lines
1.3 KiB
YAML
30 lines
1.3 KiB
YAML
---
|
|
- name: Assert Samba DNS admin password is set (vault loaded)
|
|
ansible.builtin.assert:
|
|
that:
|
|
- samba_dns_admin_pass is defined
|
|
- samba_dns_admin_pass | length > 0
|
|
fail_msg: "Missing samba_dns_admin_pass. Create inventory/group_vars/ad_dc.vault.yml with vault_samba_dns_admin_pass."
|
|
|
|
- name: List Samba DNS zones
|
|
ansible.builtin.command:
|
|
cmd: samba-tool dns zonelist {{ samba_dns_server }} -U {{ samba_dns_admin_user }}%{{ samba_dns_admin_pass }}
|
|
register: samba_zones
|
|
changed_when: false
|
|
|
|
- name: Create reverse DNS zone if missing
|
|
ansible.builtin.command:
|
|
cmd: samba-tool dns zonecreate {{ samba_dns_server }} {{ lan_reverse_zone }} -U {{ samba_dns_admin_user }}%{{ samba_dns_admin_pass }}
|
|
when: lan_reverse_zone not in samba_zones.stdout
|
|
|
|
- name: Add minimum PTR records (DC + Pi-holes)
|
|
ansible.builtin.command:
|
|
cmd: samba-tool dns add {{ samba_dns_server }} {{ lan_reverse_zone }} {{ item.last_octet }} PTR {{ item.fqdn }} -U {{ samba_dns_admin_user }}%{{ samba_dns_admin_pass }}
|
|
loop: "{{ ptr_records | default([]) }}"
|
|
register: ptr_add
|
|
changed_when: ptr_add.rc == 0
|
|
failed_when: >
|
|
ptr_add.rc != 0 and
|
|
('WERR_DNS_ERROR_RECORD_ALREADY_EXISTS' not in (ptr_add.stderr | default(''))) and
|
|
('Record already exists' not in (ptr_add.stderr | default('')))
|