netbirdio / netbird

Connect your devices into a secure WireGuard®-based overlay network with SSO, MFA and granular access controls.
https://netbird.io
BSD 3-Clause "New" or "Revised" License
11.29k stars 518 forks source link

Problems when deploying via ansible #770

Closed ykorzikowski closed 1 year ago

ykorzikowski commented 1 year ago

Describe the problem I created a ansible role for deploying netbird automatically.

For this, I retrieve the setup key via bitwarden vault, install netbird and run the up command afterwards. (Will add this to github later)

There are two issues I am dealing with right now:

  1. sometimes, the up command fails (actually most of the times). Not sure if its timing issue or something. I am trying to retry it multiple times or restarting the netbird service

  2. When re-installing my server via ansible role, connecting a second time to netbird will result into different dns name. E.g. server.example.com will be server-1.example.com after running it a second time. Question: Is there an option for delelting it automatically? Now, I need to manually delete the old netbird entry in the webinterface.

Are there plans improving automatic netbird deployment for servers?

ykorzikowski commented 1 year ago

Bit more logging:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xb9fedc]

goroutine 65 [running]:
github.com/netbirdio/netbird/client/server.(*Server).Status(0xc0002637c0, {0xc0002675c0?, 0x497ee6?}, 0xc0002675c0)
        /home/runner/work/netbird/netbird/client/server/server.go:437 +0x27c
github.com/netbirdio/netbird/client/proto._DaemonService_Status_Handler({0xf8c6c0?, 0xc0002637c0}, {0x11c8380, 0xc000267590}, 0xc0002807e0, 0x0)
        /home/runner/work/netbird/netbird/client/proto/daemon_grpc.pb.go:213 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001be1e0, {0x11d0878, 0xc000284ea0}, 0xc000678000, 0xc000267200, 0x1867a48, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.52.3/server.go:1336 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc0001be1e0, {0x11d0878, 0xc000284ea0}, 0xc000678000, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.52.3/server.go:1704 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.52.3/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.52.3/server.go:963 +0x28a
/var/log/netbird/netbird.err (END)
ykorzikowski commented 1 year ago

This is my WIP role:

---

- name: Install netbird dependencies
  apt:
    name: "{{ item }}"
    state: present
    update_cache: yes
  with_items: 
    - ca-certificates
    - curl
    - gnupg

- name: Add public key for wiretrustee
  apt_key:
    url: https://pkgs.wiretrustee.com/debian/public.key
    state: present

- name: Add wiretrustee repository into sources list
  apt_repository:
    repo: deb https://pkgs.wiretrustee.com/debian stable main
    state: present
    filename: wiretrustee.list

- name: Install netbird packages
  apt: 
    name: netbird
    state: present
    update_cache: yes

- name: Remove linux-image-amd64
  apt:
    name: "{{ item }}"
    state: absent
  with_items: 
    - linux-image-amd64
    - 'linux-image-5.10*'

- name: update-grub
  become: yes
  shell: /usr/sbin/update-grub2

- name: Start netbird service
  shell: "netbird service start"

- name: Setup netbird VPN
  shell: "netbird up --setup-key {{ netbird_setup_key }} --management-url {{ netbird_url }}"
  register: result
  until: "result is not failed"
  retries: 10
  delay: 30

- name: pause a bit for netbird coming up
  pause: seconds=15

- name: Get netbird vpn.
  shell: "netbird status |grep 'NetBird IP'|sed 's/NetBird IP: //'|sed 's#/16##'"
  register: netbirdb_ip

- name: saving netbird_ip.
  set_fact:
    netbird_host_ip: "{{netbirdb_ip['stdout_lines'][0]}}"

- debug: var=netbird_host_ip
pappz commented 1 year ago

@ykorzikowski I checked your error message and I see this issue already has been solved. More info: https://github.com/netbirdio/netbird/issues/764 In the next release the fix will be available.

mlsmaycon commented 1 year ago

@ykorzikowski the latest v0.14.6 contains the fix for the issue, can you validate?

ykorzikowski commented 1 year ago

Hey @mlsmaycon ,

Tested it now for couple of times and did not see the error in the most recent version :) so I think its solved