Skip to content

Getting Started Implementation as YAML Playbook - #49

Open
PizzaLovingNerd wants to merge 5 commits into
netbirdio:mainfrom
PizzaLovingNerd:getting-started
Open

Getting Started Implementation as YAML Playbook#49
PizzaLovingNerd wants to merge 5 commits into
netbirdio:mainfrom
PizzaLovingNerd:getting-started

Conversation

@PizzaLovingNerd

@PizzaLovingNerd PizzaLovingNerd commented Jul 10, 2026

Copy link
Copy Markdown

Summary

This PR adds an Ansible implementation of the NetBird self-hosted getting-started flow, along with an operator-focused guide.

What changed

  • Add playbooks/getting_started.yml for deploying a self-hosted NetBird server.
  • Support built-in Traefik, external Traefik, Nginx, Nginx Proxy Manager, Caddy, and manual reverse-proxy modes.
  • Support optional automated proxy configuration where appropriate.
  • Add validation for required variables and deployment prerequisites.
  • Protect existing NetBird configuration from accidental replacement unless explicitly allowed.
  • Add health checks for public and direct endpoints.
  • Add docs/getting_started.md covering requirements, inventory, variables, deployment examples, troubleshooting, and security considerations.

Validation

  • Confirmed playbooks/getting_started.yml parses successfully as YAML.

  • This playbook was testing with the following proxy configurations:

    • Internal Traefik on AlmaLinux 10.2
    • The following on Ubuntu 26.04 VPSes:
      • Internal Traefik, External Traefik, Docker network nginx, npm, caddy, manual proxy
    • The following negative test-cases were also tested on Ubuntu 26.04:
      • Missing Docker Compose, Bad Docker socket perms, existing config.yaml, blocked ports.

Summary by CodeRabbit

  • New Features
    • Added an Ansible playbook to deploy a self-hosted NetBird stack with selectable reverse-proxy modes: built-in or external Traefik, Nginx, Nginx Proxy Manager, Caddy, or manual.
    • Automatically generates configuration, Docker Compose setup, required secrets, proxy settings, and optional CrowdSec integration.
    • Includes deployment validation via health checks and prints a tailored access/summary at the end.
  • Documentation
    • Added a complete getting-started guide covering prerequisites, supported modes, troubleshooting, security considerations, and example playbook commands.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1b5e32ee-288d-43b6-9923-3458bf73681f

📥 Commits

Reviewing files that changed from the base of the PR and between 09b9e7b and 4a137b7.

📒 Files selected for processing (1)
  • playbooks/getting_started.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • playbooks/getting_started.yml

📝 Walkthrough

Walkthrough

Adds a complete Ansible playbook for deploying NetBird with configurable reverse-proxy modes, generated secrets and configuration, optional proxy installation, service orchestration, health checks, and comprehensive operator documentation.

Changes

NetBird Deployment Flow

Layer / File(s) Summary
Inputs and validation
playbooks/getting_started.yml, docs/getting_started.md
Defines deployment variables, validates proxy-specific settings and ports, and documents prerequisites, modes, and operator configuration.
Environment and configuration
playbooks/getting_started.yml, docs/getting_started.md
Derives networking values, checks Docker and Compose readiness, initializes protected secrets, and renders NetBird configuration files.
Compose and proxy artifacts
playbooks/getting_started.yml
Generates Docker Compose, Traefik, Nginx, NPM, and Caddy configuration, including optional NetBird proxy and CrowdSec services.
Runtime orchestration and operations
playbooks/getting_started.yml, docs/getting_started.md
Starts services, configures NPM through its API, performs health checks, registers CrowdSec integration, reports results, and documents troubleshooting and examples.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant Ansible
  participant DockerCompose
  participant ReverseProxy
  participant NPMAPI
  participant NetBirdServer
  Operator->>Ansible: run getting_started.yml
  Ansible->>DockerCompose: start selected services
  Ansible->>ReverseProxy: install or reload proxy configuration
  Ansible->>NPMAPI: configure proxy host when enabled
  Ansible->>NetBirdServer: create proxy token
  Ansible->>DockerCompose: start NetBird proxy
Loading

Poem

I’m a rabbit with configs tucked neat,
Hopping through proxies to make services meet.
Secrets sleep safely, ports line up bright,
Health checks blink green through the night.
NetBird takes flight—what a wonderful sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: implementing the getting-started flow as an Ansible YAML playbook.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@playbooks/getting_started.yml`:
- Around line 168-173: Require a non-empty traefik_external_network in the
external Traefik validation block for every reverse_proxy_type ==
'external_traefik' deployment, regardless of external_traefik_install_config;
add an ansible.builtin.assert alongside the existing traefik_entrypoint check
with a clear failure message.
- Around line 1028-1032: Update the Nginx gRPC location regex in
getting_started.yml and the corresponding regex in npm-advanced-config.txt to
include management\.ProxyService alongside the existing SignalExchange and
ManagementService routes, ensuring these requests use the h2c gRPC backend
instead of the dashboard route.
- Around line 471-506: Protect existing proxy configurations in the Nginx and
Traefik Compose-rendering tasks. Before each copy operation, check whether the
target docker-compose.yml already exists and fail with a clear message unless a
dedicated explicit override variable is enabled; only permit replacement when
that override is supplied. Update the task blocks around the Nginx Compose
rendering and the corresponding Traefik task, preserving normal installation
behavior when no existing file is present.
- Around line 107-116: The “use-ip” domain option must only be accepted for the
manual reverse-proxy path. Update the assertions in “Require NetBird domain” so
that when netbird_domain is “use-ip”, reverse_proxy_type must equal “manual”,
while preserving the existing FQDN validation and error guidance.
- Around line 627-635: Quote the interpolated netbird_project_dir path in the
shell redirections for both “Generate relay auth secret when missing” and
“Generate datastore encryption key when missing” tasks, using safe shell quoting
so operator-provided values cannot alter command execution.
- Around line 692-733: Change the `ansible.builtin.copy` task rendering
`config.yaml` to use mode `0600` instead of `0640`, ensuring the combined
`authSecret` and `encryptionKey` remain readable only by the owner while
preserving the existing secret-handling behavior.
- Around line 461-506: Protect the NPM bootstrap credentials rendered by the
compose task: update “Create Nginx Proxy Manager project directory when install
is requested” to use owner-only directory permissions, update “Render Nginx
Proxy Manager docker-compose.yml when install is requested” to create the file
with owner-only permissions, and add no_log: true to the rendering task to
prevent credentials from appearing in Ansible output or --diff.
- Around line 1453-1462: In the “Wait for NetBird server through public
endpoint” task, remove validate_certs: false so the HTTPS health check validates
the public TLS certificate; leave the HTTP use-ip path unchanged.
- Around line 913-920: The catch-all proxy-passthrough TCP router using
HostSNI('*') currently claims all TLS traffic on websecure; update the Traefik
labels for proxy-passthrough to use a dedicated entrypoint or a narrowly scoped
SNI/hostname rule, and configure the corresponding entrypoint or contract so
dashboard/API HTTP routers remain reachable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ae0d71fd-f476-4354-9dd7-d6bd3f678a98

📥 Commits

Reviewing files that changed from the base of the PR and between eacc1de and 09b9e7b.

📒 Files selected for processing (2)
  • docs/getting_started.md
  • playbooks/getting_started.yml

Comment thread playbooks/getting_started.yml Outdated
Comment thread playbooks/getting_started.yml
Comment thread playbooks/getting_started.yml
Comment thread playbooks/getting_started.yml
Comment thread playbooks/getting_started.yml
Comment thread playbooks/getting_started.yml
Comment thread playbooks/getting_started.yml
Comment thread playbooks/getting_started.yml Outdated
Comment on lines +1028 to +1032
location ~ ^/(signalexchange\.SignalExchange|management\.ManagementService)/ {
grpc_pass grpc://netbird_server;
grpc_read_timeout 1d;
grpc_send_timeout 1d;
grpc_socket_keepalive on;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Route management.ProxyService through gRPC too.

The Traefik configuration explicitly sends /management.ProxyService/ to the h2c backend, but the Nginx and NPM regexes omit it. Those requests fall through to the dashboard route instead.

Proposed fix
- location ~ ^/(signalexchange\.SignalExchange|management\.ManagementService)/ {
+ location ~ ^/(signalexchange\.SignalExchange|management\.(ManagementService|ProxyService))/ {

Apply the same expression to npm-advanced-config.txt.

Also applies to: 1123-1128

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@playbooks/getting_started.yml` around lines 1028 - 1032, Update the Nginx
gRPC location regex in getting_started.yml and the corresponding regex in
npm-advanced-config.txt to include management\.ProxyService alongside the
existing SignalExchange and ManagementService routes, ensuring these requests
use the h2c gRPC backend instead of the dashboard route.

Comment thread playbooks/getting_started.yml
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