birdnetpi and docker things
change txuvyvlnoxnmkoyvksmlzuznmqnutmum
commit 50f89da144bdc061741fafaac345ac6bd8630729
author Alpha Chen <alpha@kejadlen.dev>
date
parent krovzswt
diff --git a/dns.tf b/dns.tf
index 2ef7fbb..d4a367d 100644
--- a/dns.tf
+++ b/dns.tf
@@ -11,10 +11,11 @@ resource "dnsimple_zone" "zones" {
   active = true
 }
 
-resource "dnsimple_zone_record" "subdomains" {
+resource "dnsimple_zone_record" "chislan_family_subdomains" {
   for_each = {
-    auth = { zone = dnsimple_zone.zones["chislan_family"], ip = local.lotus_land_story.ip_address }
-    docs = { zone = dnsimple_zone.zones["chislan_family"], ip = local.lotus_land_story.ip_address }
+    auth      = { zone = dnsimple_zone.zones["chislan_family"], ip = local.lotus_land_story.ip_address }
+    birdnetpi = { zone = dnsimple_zone.zones["chislan_family"], ip = local.lotus_land_story.ip_address }
+    docs      = { zone = dnsimple_zone.zones["chislan_family"], ip = local.lotus_land_story.ip_address }
   }
 
   zone_name = each.value.zone.name
diff --git a/hosts.yml b/hosts.yml
index 6274816..77e49ba 100644
--- a/hosts.yml
+++ b/hosts.yml
@@ -6,7 +6,7 @@ all:
     ramble-hard:
       ansible_user: root
       ansible_python_interpreter: /usr/bin/python3
-    on-fire-within:
+    legacy-of-lunatic-kingdom:
     lotus-land-story:
     mountain-of-faith:
 local:
diff --git a/lotus-land-story/docker.yml b/lotus-land-story/docker.yml
index 79028ee..d801fa5 100644
--- a/lotus-land-story/docker.yml
+++ b/lotus-land-story/docker.yml
@@ -3,48 +3,6 @@
   hosts: lotus-land-story
   tasks:
 
-    - name: Install Docker requirements
-      ansible.builtin.apt:
-        pkg:
-          - ca-certificates
-          - curl
-          - gnupg
-        state: present
-
-    - name: Make /etc/apt/keyrings
-      ansible.builtin.file:
-        path: /etc/apt/keyrings
-        state: directory
-        mode: "0755"
-
-    - name: Download Docker GPG key
-      ansible.builtin.shell: |
-        set -o pipefail
-        curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
-      args:
-        creates: /etc/apt/keyrings/docker.gpg
-
-    - name: Get architecture
-      ansible.builtin.command: dpkg --print-architecture
-      register: arch
-      changed_when: arch.rc != 0
-
-    - name: Set up Docker repository
-      ansible.builtin.template:
-        src: templates/docker.list
-        dest: /etc/apt/sources.list.d/docker.list
-        mode: "0644"
-
-    - name: Install Docker
-      ansible.builtin.apt:
-        pkg:
-          - docker-ce
-          - docker-ce-cli
-          - containerd.io
-          - docker-buildx-plugin
-          - docker-compose-plugin
-        update_cache: true
-
     - name: Create Docker volume location
       ansible.builtin.file:
         path: /mnt/lotus-land-story/docker
diff --git a/lotus-land-story/main.yml b/lotus-land-story/main.yml
index 564c7f3..09f3cd9 100644
--- a/lotus-land-story/main.yml
+++ b/lotus-land-story/main.yml
@@ -24,6 +24,7 @@
         state: present
 
 - import_playbook: ../playbooks/tailscale.yml # noqa: name[play]
+- import_playbook: ../playbooks/docker.yml    # noqa: name[play]
 - import_playbook: docker.yml                 # noqa: name[play]
 - import_playbook: postgres.yml               # noqa: name[play]
 - import_playbook: redis.yml                  # noqa: name[play]
diff --git a/lotus-land-story/templates/Caddyfile b/lotus-land-story/templates/Caddyfile
index 52a6be2..a6acd4e 100644
--- a/lotus-land-story/templates/Caddyfile
+++ b/lotus-land-story/templates/Caddyfile
@@ -149,11 +149,17 @@ home-assistant {
 pihole {
 	tls internal
 	bind tailscale/pihole
-	reverse_proxy mountain-of-faith:80
+	reverse_proxy mountain-of-faith:8080
 }
 
 ### External
 
+birdnetpi.chislan.family
+	log
+
+	reverse_proxy mountain-of-faith:8081
+}
+
 git.kejadlen.dev {
 	log
 
diff --git a/main.tf b/main.tf
index 6a00300..89d824c 100644
--- a/main.tf
+++ b/main.tf
@@ -41,9 +41,8 @@ provider "linode" {
 }
 
 provider "pihole" {
-  # url = "https://pihole.kejadlen.dev" # on-fire-within
-  url = "http://mountain-of-faith"
-  # api_token = # PIHOLE_API_TOKEN
+  url = "http://mountain-of-faith:8080"
+  password = var.pihole.password
 }
 
 provider "tailscale" {
@@ -60,13 +59,15 @@ variable "dnsimple" {
   nullable = false
 }
 
-variable "soa_email" {
-  type     = string
+variable "pihole" {
+  type = object({
+    password   = string
+  })
   nullable = false
 }
 
-variable "subdomains" {
-  type     = map(list(string))
+variable "soa_email" {
+  type     = string
   nullable = false
 }
 
@@ -113,11 +114,14 @@ resource "linode_domain" "chislan_family" {
   soa_email = var.soa_email
 }
 
-resource "pihole_dns_record" "git_kejadlen_dev" {
-  for_each = toset(["git.kejadlen.dev"])
+resource "pihole_dns_record" "domains" {
+  for_each = {
+    "birdnetpi" = data.tailscale_device.mountain_of_faith.addresses.0
+    "git.kejadlen.dev" = data.tailscale_device.lotus_land_story.addresses.0
+  }
 
   domain = each.key
-  ip     = data.tailscale_device.lotus_land_story.addresses.0
+  ip     = each.value
 }
 
 # doesn't seem to work
diff --git a/mountain-of-faith/caddy.yml b/mountain-of-faith/caddy.yml
index e979387..af696c9 100644
--- a/mountain-of-faith/caddy.yml
+++ b/mountain-of-faith/caddy.yml
@@ -46,34 +46,21 @@
         state: present
         update_cache: true
 
-    # https://github.com/caddyserver/caddy/issues/5372#issuecomment-1755730902
-    - name: Allow Caddy to resolve mDNS
-      block:
-
-        - name: Install systemd-resolved
-          ansible.builtin.apt:
-            name: systemd-resolved
-
-        - name: Configure resolved.conf to enable MulticastDNS
-          ansible.builtin.lineinfile:
-            path: /etc/systemd/resolved.conf
-            regexp: '^#?MulticastDNS='
-            line: 'MulticastDNS=yes'
-          notify: Restart systemd-resolved
-
     - name: Configure Caddy
       ansible.builtin.copy:
         content: |
-          {
-            debug
-          }
-
-          :80 {
-            reverse_proxy hopeless-masquerade.local
-          }
-
-          http://pihole {
-            reverse_proxy :8080
+          # Since I don't want to run Tailscale on the BirdNET-Pi, this uses
+          # mountain-of-faith as a passthrough since they're on the same
+          # network.
+          :8081 {
+            # It would be nice for this to be hopeless-masquerade.local, but
+            # Caddy can't resolve mDNS (see below issue). The workaround in the
+            # issue of using systemd-resolved also doesn't work since then we
+            # have contention over /etc/resolv.conf between systemd-resolved
+            # and Tailscale. So we use just the raw IP for now.
+            #
+            # https://github.com/caddyserver/caddy/issues/5372
+            reverse_proxy 192.168.2.161
           }
         dest: /etc/caddy/Caddyfile
         mode: "0644"
diff --git a/playbooks/docker.yml b/playbooks/docker.yml
index c89c09f..e9bfe78 100644
--- a/playbooks/docker.yml
+++ b/playbooks/docker.yml
@@ -5,12 +5,6 @@
   become: true
   tasks:
 
-    - name: Assert distribution is Debian
-      ansible.builtin.assert:
-        that:
-          - ansible_distribution == "Debian"
-        fail_msg: "This playbook only supports Debian distributions"
-
     # sudo apt-get update
     # sudo apt-get install ca-certificates curl
     - name: Install required packages
@@ -18,6 +12,7 @@
         name:
           - ca-certificates
           - curl
+          - gnupg # for the signing keys
         state: present
         update_cache: true
 
@@ -27,7 +22,7 @@
     - name: Download Docker GPG key
       ansible.builtin.get_url:
         url: https://download.docker.com/linux/debian/gpg
-        dest: /usr/share/keyrings/docker.asc
+        dest: /etc/apt/keyrings/docker.asc
         mode: "0644"
 
     - name: Get system architecture
@@ -38,7 +33,9 @@
     # echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
     - name: Add Docker repository
       ansible.builtin.apt_repository:
-        repo: deb [arch={{ dpkg_arch.stdout }} signed-by=/usr/share/keyrings/docker.asc] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable
+        repo: >-
+          deb [arch={{ dpkg_arch.stdout }} signed-by=/etc/apt/keyrings/docker.asc]
+          https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable
         state: present
 
     # sudo apt-get update