Skip to content

Setup redundant DNS with AdGuard Home Sync - #173

Merged
bubacoder merged 1 commit into
mainfrom
feature/redundant-dns
Aug 8, 2025
Merged

Setup redundant DNS with AdGuard Home Sync#173
bubacoder merged 1 commit into
mainfrom
feature/redundant-dns

Conversation

@bubacoder

@bubacoder bubacoder commented Aug 8, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added configuration and orchestration for an AdGuard Home synchronization service, enabling automated syncing between AdGuard Home instances.
    • Introduced new environment variables for secondary node configuration and local node IP addresses.
    • Added environment variables for AdGuard Home credentials with placeholders for secure values.
  • Improvements

    • Updated environment variable placeholders for sensitive credentials to encourage secure values.
    • Enhanced masking of sensitive environment variables in example files by including usernames.
    • Expanded documentation and setup instructions for AdGuard Home services, including router DNS configuration and best practices for running multiple instances.

@coderabbitai

coderabbitai Bot commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce new environment variables for secondary node configuration and local credentials, add a new AdGuard Home synchronization service using Docker Compose, update service states, and enhance environment variable masking logic in a Python script. Comments and best practices are also updated in configuration files, with no changes to application control flow.

Changes

Cohort / File(s) Change Summary
Secondary Node Environment Variables
config-example/docker/.env
Added SECOND_NODE and SECOND_NODE_IP environment variables for defining a secondary node named "hive" and its IP address.
Local Host Configuration and Credentials
config-example/docker/myhost/.env
Added LOCAL_NODE_IP, ADGUARDHOME_USERNAME, ADGUARDHOME_PASSWORD; changed UNIFI_LOCAL_VIEWONLY_USERNAME to a secure placeholder; introduced a "Hosts" section.
Service State Update
config-example/docker/myhost/services.yaml
Added a new service entry adguardhome-sync (state: "up") under the "infra" group.
AdGuard Home Sync Service Definition
docker/infra/adguardhome-sync.yaml
Introduced a new Docker Compose file defining the adguardhome-sync service, including environment variables, scheduling, Traefik integration, and metadata for UI grouping and documentation.
AdGuard Home Service Configuration
docker/infra/adguardhome.yaml
Updated comments with setup instructions and best practices; changed DNS port binding from ${MAIN_NODE_IP} to ${LOCAL_NODE_IP} for both TCP and UDP on port 53.
Environment Variable Masking Logic
scripts/create-example-env.py
Added "USERNAME" to the list of substrings for masking sensitive environment variables, ensuring variables with "USERNAME" are replaced with placeholders in generated files.
Router Configuration Documentation
docs/setup.md
Added instruction to set the DHCP DNS server address to the IP of the AdGuard Home service for both instances when using AdGuard Home Sync.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/redundant-dns

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
docker/infra/adguardhome.yaml (2)

3-7: Fix YAML lint issue (trailing spaces) and a typo in comments.

Yamllint flags trailing spaces at Line 3; also fix “alow” -> “allow”.

-# To fix "listen tcp4 0.0.0.0:53: bind: address already in use" error on Ubuntu: disable `DNSStubListener` (see Ansible).  
-# Follow the AdguardHome installation wizard for first-time configuration. (Note: Firefox may not alow access to the admin interface)
+# To fix "listen tcp4 0.0.0.0:53: bind: address already in use" error on Ubuntu: disable `DNSStubListener` (see Ansible).
+# Follow the AdguardHome installation wizard for first-time configuration. (Note: Firefox may not allow access to the admin interface)

31-31: Optional: Restrict the admin UI port or rely solely on Traefik.

You can bind 3000 to LOCAL_NODE_IP (or remove it) if Traefik fronts the UI to reduce exposure.

# Option A (restrict to local IP):
- "3000:3000/tcp"
+ "${LOCAL_NODE_IP}:3000:3000/tcp"

# Option B (remove mapping if only Traefik is used):
# - 3000:3000/tcp
config-example/docker/myhost/.env (1)

40-42: Reorder ADGUARDHOME_ keys to satisfy dotenv-linter UnorderedKey rule.*

Keep quotes if that’s your convention; just reorder PASSWORD before USERNAME.

-ADGUARDHOME_USERNAME="use-some-very-secure-value-here"
-ADGUARDHOME_PASSWORD="use-some-very-secure-value-here"
+ADGUARDHOME_PASSWORD="use-some-very-secure-value-here"
+ADGUARDHOME_USERNAME="use-some-very-secure-value-here"
docker/infra/adguardhome-sync.yaml (2)

22-27: Quote URL environment values to avoid YAML parsing edge cases

Unquoted URLs can trip linters or tooling (because of colon and ${...} expansion). Quote them for robustness.

-      ORIGIN_URL: http://${MAIN_NODE_IP}:3000
+      ORIGIN_URL: "http://${MAIN_NODE_IP}:3000"
-      REPLICA1_URL: http://${SECOND_NODE_IP}:3000
+      REPLICA1_URL: "http://${SECOND_NODE_IP}:3000"

12-12: Verify Docker Compose version for top-level name:

We weren’t able to run docker compose version in the sandbox (Docker isn’t installed), so please confirm your deployment environments support Docker Compose V2.20+ if you intend to keep the top-level name: field. If any environment uses an older version, remove the name: line and define the project name via the COMPOSE_PROJECT_NAME environment variable instead.

• File: docker/infra/adguardhome-sync.yaml
Line 12 – name: adguardhome-sync

Suggested fallback patch:

- name: adguardhome-sync

Then in your environment (e.g., .env, CI):

COMPOSE_PROJECT_NAME=adguardhome-sync

Please verify your Compose versions across all environments. Let me know if you’d like a patch that removes the name: field and adds documentation for using COMPOSE_PROJECT_NAME.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68d8407 and dd8c2f6.

📒 Files selected for processing (6)
  • config-example/docker/.env (1 hunks)
  • config-example/docker/myhost/.env (3 hunks)
  • config-example/docker/myhost/services.yaml (1 hunks)
  • docker/infra/adguardhome-sync.yaml (1 hunks)
  • docker/infra/adguardhome.yaml (2 hunks)
  • scripts/create-example-env.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{sh,Dockerfile,yml,yaml,tf}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Follow the pre-commit rules defined in .pre-commit-config.yaml, which includes linting for shell scripts, Dockerfiles, YAML files, Ansible playbooks, and Terraform configurations.

Files:

  • docker/infra/adguardhome.yaml
  • config-example/docker/myhost/services.yaml
  • docker/infra/adguardhome-sync.yaml
docker/**/*.{yml,yaml}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Docker Compose files for services should be placed under the docker/ directory, organized by service type (e.g., security, media, storage, monitoring).

Files:

  • docker/infra/adguardhome.yaml
  • docker/infra/adguardhome-sync.yaml
config-example/**

📄 CodeRabbit Inference Engine (CLAUDE.md)

Example configuration files should be placed under the config-example/ directory.

Files:

  • config-example/docker/myhost/services.yaml
🧠 Learnings (2)
📚 Learning: 2025-08-06T20:29:29.578Z
Learnt from: CR
PR: bubacoder/infra#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-06T20:29:29.578Z
Learning: Applies to docker/**/*.{yml,yaml} : Docker Compose files for services should be placed under the docker/ directory, organized by service type (e.g., security, media, storage, monitoring).

Applied to files:

  • docker/infra/adguardhome-sync.yaml
📚 Learning: 2025-08-06T20:29:29.578Z
Learnt from: CR
PR: bubacoder/infra#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-06T20:29:29.578Z
Learning: Use Docker and Docker Compose for containerized services.

Applied to files:

  • docker/infra/adguardhome-sync.yaml
🪛 YAMLlint (1.37.1)
docker/infra/adguardhome.yaml

[error] 3-3: trailing spaces

(trailing-spaces)

🪛 dotenv-linter (3.3.0)
config-example/docker/myhost/.env

[warning] 40-40: [QuoteCharacter] The value has quote characters (', ")


[warning] 41-41: [QuoteCharacter] The value has quote characters (', ")


[warning] 41-41: [UnorderedKey] The ADGUARDHOME_PASSWORD key should go before the ADGUARDHOME_USERNAME key


[warning] 67-67: [QuoteCharacter] The value has quote characters (', ")

🔇 Additional comments (7)
config-example/docker/myhost/services.yaml (1)

29-30: Compose definition confirmed under docker/infra/adguardhome-sync.yaml

  • Found file: docker/infra/adguardhome-sync.yaml
  • Contains matching name: adguardhome-sync service block

Everything aligns with the repository layout. No further changes needed.

config-example/docker/.env (1)

16-17: Verify SECOND_NODE variable usage

  • docker/infra/adguardhome-sync.yaml:25 references SECOND_NODE_IP for REPLICA1_URL.
  • No occurrences of SECOND_NODE (without _IP) found elsewhere.

Please confirm whether SECOND_NODE is intended for use in other configs or scripts (e.g., Docker Compose, orchestration scripts), and either add the necessary references or remove the unused variable.

scripts/create-example-env.py (1)

5-13: Masking USERNAME fields is appropriate and aligns with new vars.

This will properly mask ADGUARDHOME_USERNAME and UNIFI_*_USERNAME while preserving ADMIN_USER via GENERALIZE precedence.

docker/infra/adguardhome.yaml (1)

23-24: LOCAL_NODE_IP DNS bindings verified
The use of LOCAL_NODE_IP on lines 23–24 is correct, and there are no remaining MAIN_NODE_IP references in docker/infra/adguardhome.yaml.

config-example/docker/myhost/.env (2)

28-31: LOCAL_NODE_IP addition is consistent with compose changes.

Matches the adguardhome.yaml port binding. No further action.


67-67: Username placeholder switch aligns with new masking logic.

Good move to avoid committing real usernames in example configs.

docker/infra/adguardhome-sync.yaml (1)

15-21: Service setup, image pin, and cron look good

Image, command, restart policy, and the 2-hour cron are sensible defaults. Nice touch linking to the upstream config reference.

Comment thread docker/infra/adguardhome-sync.yaml
@bubacoder
bubacoder force-pushed the feature/redundant-dns branch from dd8c2f6 to be32ae4 Compare August 8, 2025 09:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
config-example/docker/myhost/.env (1)

67-67: Fix dotenv-linter warning: drop quotes

Quotes are unnecessary here and flagged by dotenv-linter.

-UNIFI_LOCAL_VIEWONLY_USERNAME="use-some-very-secure-value-here"
+UNIFI_LOCAL_VIEWONLY_USERNAME=use-some-very-secure-value-here
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd8c2f6 and be32ae4.

📒 Files selected for processing (7)
  • config-example/docker/.env (1 hunks)
  • config-example/docker/myhost/.env (3 hunks)
  • config-example/docker/myhost/services.yaml (1 hunks)
  • docker/infra/adguardhome-sync.yaml (1 hunks)
  • docker/infra/adguardhome.yaml (2 hunks)
  • docs/setup.md (1 hunks)
  • scripts/create-example-env.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/setup.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • config-example/docker/myhost/services.yaml
  • config-example/docker/.env
  • scripts/create-example-env.py
  • docker/infra/adguardhome-sync.yaml
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{sh,Dockerfile,yml,yaml,tf}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Follow the pre-commit rules defined in .pre-commit-config.yaml, which includes linting for shell scripts, Dockerfiles, YAML files, Ansible playbooks, and Terraform configurations.

Files:

  • docker/infra/adguardhome.yaml
docker/**/*.{yml,yaml}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Docker Compose files for services should be placed under the docker/ directory, organized by service type (e.g., security, media, storage, monitoring).

Files:

  • docker/infra/adguardhome.yaml
🪛 dotenv-linter (3.3.0)
config-example/docker/myhost/.env

[warning] 40-40: [QuoteCharacter] The value has quote characters (', ")


[warning] 41-41: [QuoteCharacter] The value has quote characters (', ")


[warning] 41-41: [UnorderedKey] The ADGUARDHOME_PASSWORD key should go before the ADGUARDHOME_USERNAME key


[warning] 67-67: [QuoteCharacter] The value has quote characters (', ")

🪛 YAMLlint (1.37.1)
docker/infra/adguardhome.yaml

[error] 3-3: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: check
🔇 Additional comments (1)
config-example/docker/myhost/.env (1)

28-31: LOCAL_NODE_IP addition looks good

Host-scoped bind IP is appropriate and aligns with docker/infra/adguardhome.yaml usage.

Comment thread config-example/docker/myhost/.env
Comment thread docker/infra/adguardhome.yaml
Comment thread docker/infra/adguardhome.yaml
@bubacoder
bubacoder merged commit bb2a7ca into main Aug 8, 2025
4 checks passed
@bubacoder
bubacoder deleted the feature/redundant-dns branch August 8, 2025 10:16
@coderabbitai coderabbitai Bot mentioned this pull request Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant