10_coredns.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ---
  2. # playbooks/10_coredns.yml
  3. # Update CoreDNS records on coredns_host
  4. - name: "CoreDNS | Update DNS records"
  5. hosts: coredns_host
  6. become: true
  7. gather_facts: false
  8. tags:
  9. - coredns
  10. vars:
  11. dns_records:
  12. - name: "vault.{{ domain }}."
  13. type: A
  14. ttl: 3600
  15. value: "{{ nginx_proxy_ip }}"
  16. - name: "ollama-api.{{ domain }}."
  17. type: A
  18. ttl: 3600
  19. value: "{{ nginx_proxy_ip }}"
  20. - name: "idm.{{ domain }}."
  21. type: A
  22. ttl: 3600
  23. value: "{{ nginx_proxy_ip }}"
  24. tasks:
  25. - name: "CoreDNS | Add vault DNS record"
  26. ansible.builtin.lineinfile:
  27. path: "{{ coredns_zone_file }}"
  28. line: "vault.{{ domain }}. 3600 IN A {{ nginx_proxy_ip }}"
  29. regexp: "^vault\\.{{ domain | replace('.', '\\.') }}\\."
  30. insertafter: EOF
  31. state: present
  32. register: vault_dns_record
  33. tags:
  34. - coredns-records
  35. - name: "CoreDNS | Add ollama-api DNS record"
  36. ansible.builtin.lineinfile:
  37. path: "{{ coredns_zone_file }}"
  38. line: "ollama-api.{{ domain }}. 3600 IN A {{ nginx_proxy_ip }}"
  39. regexp: "^ollama-api\\.{{ domain | replace('.', '\\.') }}\\."
  40. insertafter: EOF
  41. state: present
  42. register: ollama_dns_record
  43. tags:
  44. - coredns-records
  45. - name: "CoreDNS | Add idm (Keycloak) DNS record"
  46. ansible.builtin.lineinfile:
  47. path: "{{ coredns_zone_file }}"
  48. line: "idm.{{ domain }}. 3600 IN A {{ nginx_proxy_ip }}"
  49. regexp: "^idm\\.{{ domain | replace('.', '\\.') }}\\."
  50. insertafter: EOF
  51. state: present
  52. register: idm_dns_record
  53. tags:
  54. - coredns-records
  55. - name: "CoreDNS | Restart CoreDNS container to reload zone file"
  56. ansible.builtin.command: docker restart {{ coredns_container_name }}
  57. changed_when: true
  58. tags:
  59. - coredns-reload