diff --git a/playbooks/pihole-dns.yml b/playbooks/pihole-dns.yml new file mode 100644 index 0000000..06eb790 --- /dev/null +++ b/playbooks/pihole-dns.yml @@ -0,0 +1,37 @@ +--- +- name: Configure Pi-hole local DNS records + hosts: pihole + vars: + dns_domain: lab.directlx.dev + dns_records: + - { ip: "192.168.200.106", hostname: "ansible-node" } + - { ip: "192.168.200.10", hostname: "proxmox-00" } + - { ip: "192.168.200.11", hostname: "proxmox-01" } + - { ip: "192.168.200.12", hostname: "proxmox-02" } + - { ip: "192.168.200.103", hostname: "postgres" } + - { ip: "192.168.200.110", hostname: "mysql" } + - { ip: "192.168.200.111", hostname: "mongo" } + - { ip: "192.168.200.65", hostname: "nginx" } + - { ip: "192.168.200.71", hostname: "npm" } + - { ip: "192.168.200.200", hostname: "docker" } + - { ip: "192.168.200.100", hostname: "pihole" } + - { ip: "192.168.200.102", hostname: "gitea" } + - { ip: "192.168.200.91", hostname: "jenkins" } + - { ip: "192.168.200.112", hostname: "hiveops" } + - { ip: "192.168.200.114", hostname: "smartjournal" } + - { ip: "192.168.200.61", hostname: "odoo" } + + tasks: + - name: Create Pi-hole custom DNS records + ansible.builtin.template: + src: ../templates/pihole-custom-list.j2 + dest: /etc/pihole/custom.list + owner: root + group: root + mode: '0644' + notify: Restart pihole dns + + handlers: + - name: Restart pihole dns + ansible.builtin.command: pihole restartdns + changed_when: true diff --git a/templates/.gitkeep b/templates/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/templates/pihole-custom-list.j2 b/templates/pihole-custom-list.j2 new file mode 100644 index 0000000..5a572fd --- /dev/null +++ b/templates/pihole-custom-list.j2 @@ -0,0 +1,7 @@ +# Pi-hole local DNS records +# Managed by Ansible - do not edit manually +# Domain: {{ dns_domain }} + +{% for record in dns_records %} +{{ record.ip }} {{ record.hostname }}.{{ dns_domain }} {{ record.hostname }} +{% endfor %}