prole/infrastructure/roles/samba_dns/tasks/ensure_a.yml
chrisfu b8a55888be checkpoint: update GKE deployment docs and infra changes
Summarize CLAUDE.md updates:

- Document both live GKE clusters as e2-standard-2 x3 in us-west3 and note stale app default in code.

- Call out DB cluster naming mismatch between conf (knoe-dev-cnpg-0) and code default (knoe-cnpg-0).

- Add SSD quota guidance: 300GB fully consumed by CNPG, so non-CNPG PVCs must use standard/pd-standard.

- Refresh reset script reference and quota section details to match current runtime state.

Co-authored-by: Junie <junie@jetbrains.com>
2026-04-18 07:18:10 -07:00

47 lines
1.8 KiB
YAML

---
- name: Derive record name within zone from fqdn
ansible.builtin.set_fact:
samba_dns_record_name: >-
{{
(item.fqdn | regex_replace('\\.?$','')) |
regex_replace('\\.' ~ (prole_domain | regex_escape) ~ '$', '')
}}
- name: Query existing A records
ansible.builtin.command:
cmd: samba-tool dns query {{ samba_dns_server }} {{ prole_domain }} {{ samba_dns_record_name }} A -U {{ samba_dns_admin_user }}%{{ samba_dns_admin_pass }}
register: a_query
changed_when: false
failed_when: false
- name: Parse existing A record values
ansible.builtin.set_fact:
a_existing_values: >-
{{
(a_query.stdout | default('') |
regex_findall('\\bA\\s+([0-9]{1,3}(?:\\.[0-9]{1,3}){3})\\b') |
list)
}}
- name: Remove stale A records
ansible.builtin.command:
cmd: samba-tool dns delete {{ samba_dns_server }} {{ prole_domain }} {{ samba_dns_record_name }} A {{ a_value }} -U {{ samba_dns_admin_user }}%{{ samba_dns_admin_pass }}
loop: "{{ a_existing_values | difference(item.ipv4s) }}"
loop_control:
loop_var: a_value
when: (a_existing_values | difference(item.ipv4s) | length) > 0
- name: Add missing A records
ansible.builtin.command:
cmd: samba-tool dns add {{ samba_dns_server }} {{ prole_domain }} {{ samba_dns_record_name }} A {{ a_target_ip }} -U {{ samba_dns_admin_user }}%{{ samba_dns_admin_pass }}
register: a_add
changed_when: a_add.rc == 0
failed_when: >
a_add.rc != 0 and
('WERR_DNS_ERROR_RECORD_ALREADY_EXISTS' not in (a_add.stderr | default(''))) and
('Record already exists' not in (a_add.stderr | default('')))
loop: "{{ item.ipv4s | difference(a_existing_values) }}"
loop_control:
loop_var: a_target_ip
when: (item.ipv4s | difference(a_existing_values) | length) > 0