[GH-ISSUE #2103] Automating the update of the NetBird client on a Windows system via Ansible is not working #4269

Open
opened 2026-08-05 00:56:45 -04:00 by saavagebueno · 6 comments
Owner

Originally created by @dannykorpan on GitHub (Jun 7, 2024).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/2103

Describe the problem
Dear Community,

I've tried extensively to automate the update of NetBird with Ansible on a Windows system for a business environment, but it always gets stuck during the silent uninstallation or installation of NetBird. The uninstaller or installer always hangs. Neither the silent uninstall nor the installation works. The playbook runs fine, but NetBird does not perform any uninstallation or installation. The Ansible user is accessing the Windows machine via an OpenSSH server and also has Administrator privileges.

Is there anybody out there who has already automated the update of NetBird on a Windows system via Ansible? Or does anybody have any hints for troubleshooting?

Here is my Ansible playbook:

---
- name: Update Netbird package on Windows
  hosts: windows_hosts
  tasks:
    - name: Get latest Netbird release info using PowerShell
      win_shell: |
        $url = "https://api.github.com/repos/netbirdio/netbird/releases/latest"
        $response = Invoke-RestMethod -Uri $url
        $asset = $response.assets | Where-Object { $_.name -match "netbird_installer_.*_windows_amd64.exe" }
        $asset.browser_download_url
      register: release_info

    - name: Set download URL for the latest Netbird EXE
      set_fact:
        netbird_exe_url: "{{ release_info.stdout }}"

    - name: Download latest Netbird exe
      win_get_url:
        url: "{{ netbird_exe_url }}"
        dest: C:\Windows\Temp\netbird_installer.exe

    - name: Stop Netbird service
      win_service:
        name: Netbird
        state: stopped
      ignore_errors: yes

    - name: Stop all applications containing 'netbird' in the name
      win_shell: |
        Get-Process | Where-Object { $_.Name -like "*netbird*" } | Stop-Process -Force
      ignore_errors: yes

    - name: Uninstall existing Netbird application
      win_shell: |
        Start-Process -FilePath "cmd.exe" -ArgumentList "/c C:\Program Files\Netbird\netbird_uninstall.exe /S"
# ALTERNATIVE
# NOT WORKING
#      win_command:
#        cmd: '"C:\Program Files\Netbird\netbird_uninstall.exe" "/S"'

    - name: Install Netbird
      win_shell: |
        Start-Process -FilePath "cmd.exe" -ArgumentList "/c C:\Windows\Temp\netbird_installer.exe /S"
# ALTERNATIVE
# NOT WORKING
#      win_command:
#        cmd: '"C:\Windows\Temp\netbird_installer.exe" "/S"'

    - name: Start Netbird service
      win_service:
        name: Netbird
        state: started

    - name: Run Netbird enrollment
      win_shell: |
        & "C:\Program Files\Netbird\netbird.exe" up --setup-key MY_ENROLLMENT_KEY
      register: netbird_setup
      ignore_errors: yes

    - name: Verify Netbird version
      win_shell: |
        netbird version
      register: netbird_version

    - debug: var=netbird_version.stdout_lines

    - name: Delete Netbird installer
      win_file:
        path: C:\Windows\Temp\netbird_installer.exe
        state: absent

Thank you in advance for any help,
Danny

Originally created by @dannykorpan on GitHub (Jun 7, 2024). Original GitHub issue: https://github.com/netbirdio/netbird/issues/2103 **Describe the problem** Dear Community, I've tried extensively to automate the update of NetBird with Ansible on a Windows system for a business environment, but it always gets stuck during the silent uninstallation or installation of NetBird. The uninstaller or installer always hangs. Neither the silent uninstall nor the installation works. The playbook runs fine, but NetBird does not perform any uninstallation or installation. The Ansible user is accessing the Windows machine via an OpenSSH server and also has Administrator privileges. Is there anybody out there who has already automated the update of NetBird on a Windows system via Ansible? Or does anybody have any hints for troubleshooting? Here is my Ansible playbook: ``` --- - name: Update Netbird package on Windows hosts: windows_hosts tasks: - name: Get latest Netbird release info using PowerShell win_shell: | $url = "https://api.github.com/repos/netbirdio/netbird/releases/latest" $response = Invoke-RestMethod -Uri $url $asset = $response.assets | Where-Object { $_.name -match "netbird_installer_.*_windows_amd64.exe" } $asset.browser_download_url register: release_info - name: Set download URL for the latest Netbird EXE set_fact: netbird_exe_url: "{{ release_info.stdout }}" - name: Download latest Netbird exe win_get_url: url: "{{ netbird_exe_url }}" dest: C:\Windows\Temp\netbird_installer.exe - name: Stop Netbird service win_service: name: Netbird state: stopped ignore_errors: yes - name: Stop all applications containing 'netbird' in the name win_shell: | Get-Process | Where-Object { $_.Name -like "*netbird*" } | Stop-Process -Force ignore_errors: yes - name: Uninstall existing Netbird application win_shell: | Start-Process -FilePath "cmd.exe" -ArgumentList "/c C:\Program Files\Netbird\netbird_uninstall.exe /S" # ALTERNATIVE # NOT WORKING # win_command: # cmd: '"C:\Program Files\Netbird\netbird_uninstall.exe" "/S"' - name: Install Netbird win_shell: | Start-Process -FilePath "cmd.exe" -ArgumentList "/c C:\Windows\Temp\netbird_installer.exe /S" # ALTERNATIVE # NOT WORKING # win_command: # cmd: '"C:\Windows\Temp\netbird_installer.exe" "/S"' - name: Start Netbird service win_service: name: Netbird state: started - name: Run Netbird enrollment win_shell: | & "C:\Program Files\Netbird\netbird.exe" up --setup-key MY_ENROLLMENT_KEY register: netbird_setup ignore_errors: yes - name: Verify Netbird version win_shell: | netbird version register: netbird_version - debug: var=netbird_version.stdout_lines - name: Delete Netbird installer win_file: path: C:\Windows\Temp\netbird_installer.exe state: absent ``` Thank you in advance for any help, Danny
saavagebueno added the triage-needed label 2026-08-05 00:56:45 -04:00
Author
Owner

@lixmal commented on GitHub (Jun 7, 2024):

Have you tried with the msi package as well? That one should work with an unattended install

<!-- gh-comment-id:2154517073 --> @lixmal commented on GitHub (Jun 7, 2024): Have you tried with the msi package as well? That one should work with an unattended install
Author
Owner

@dannykorpan commented on GitHub (Jun 7, 2024):

The first enrollment was done via the exe.

<!-- gh-comment-id:2154569002 --> @dannykorpan commented on GitHub (Jun 7, 2024): The first enrollment was done via the exe.
Author
Owner

@dannykorpan commented on GitHub (Jun 7, 2024):

After a lot of trial and error, this playbook works. The uninstallation and installation processes are working fine, but they run into a timeout before the playbook continues. The timeout occurs with either the exe or msi file. There is room for improvement in the playbook, as well as in the installation and uninstallation files.

---
- name: Update Netbird package on Windows
  hosts: windows_hosts
  tasks:
    - name: Get latest Netbird release info using PowerShell
      win_shell: |
        $url = "https://api.github.com/repos/netbirdio/netbird/releases/latest"
        $response = Invoke-RestMethod -Uri $url
        $asset = $response.assets | Where-Object { $_.name -match "netbird_installer_.*_windows_amd64.exe" }
        $asset.browser_download_url
      register: release_info

    - name: Set download URL for the latest Netbird EXE
      set_fact:
        netbird_exe_url: "{{ release_info.stdout }}"

    - name: Download latest Netbird exe
      win_get_url:
        url: "{{ netbird_exe_url }}"
        dest: C:\Windows\Temp\netbird_installer.exe

    - name: Stop Netbird service
      win_service:
        name: Netbird
        state: stopped
      ignore_errors: yes

    - name: Stop all applications containing 'netbird' in the name
      win_shell: |
        Get-Process | Where-Object { $_.Name -like "*netbird*" } | Stop-Process -Force
      ignore_errors: yes

    - name: Uninstall existing Netbird Installation
      ansible.windows.win_package:
        path: C:\Program Files\Netbird\netbird_uninstall.exe
        product_id: Netbird
        arguments: /S
        state: absent
        wait_for_children: true
        chdir: C:\Program Files\Netbird
      ignore_errors: yes

    - name: Install Netbird MSI
      ansible.windows.win_package:
        path: C:\Windows\Temp\netbird_installer.exe
        product_id: Netbird
        arguments: /S
        state: present
        wait_for_children: true
      ignore_errors: yes

    - name: Start Netbird service
      win_service:
        name: Netbird
        state: started

    - name: Run Netbird enrollment
      win_shell: |
        & "C:\Program Files\Netbird\netbird.exe" up --setup-key MY_ENROLLMENT_KEY
      register: netbird_setup
      ignore_errors: yes

    - name: Verify Netbird version
      win_shell: |
        netbird version
      register: netbird_version

    - debug: var=netbird_version.stdout_lines

    - name: Delete Netbird installer
      win_file:
        path: C:\Windows\Temp\netbird_installer.exe
        state: absent
<!-- gh-comment-id:2154627378 --> @dannykorpan commented on GitHub (Jun 7, 2024): After a lot of trial and error, this playbook works. The uninstallation and installation processes are working fine, but they run into a timeout before the playbook continues. The timeout occurs with either the exe or msi file. There is room for improvement in the playbook, as well as in the installation and uninstallation files. ``` --- - name: Update Netbird package on Windows hosts: windows_hosts tasks: - name: Get latest Netbird release info using PowerShell win_shell: | $url = "https://api.github.com/repos/netbirdio/netbird/releases/latest" $response = Invoke-RestMethod -Uri $url $asset = $response.assets | Where-Object { $_.name -match "netbird_installer_.*_windows_amd64.exe" } $asset.browser_download_url register: release_info - name: Set download URL for the latest Netbird EXE set_fact: netbird_exe_url: "{{ release_info.stdout }}" - name: Download latest Netbird exe win_get_url: url: "{{ netbird_exe_url }}" dest: C:\Windows\Temp\netbird_installer.exe - name: Stop Netbird service win_service: name: Netbird state: stopped ignore_errors: yes - name: Stop all applications containing 'netbird' in the name win_shell: | Get-Process | Where-Object { $_.Name -like "*netbird*" } | Stop-Process -Force ignore_errors: yes - name: Uninstall existing Netbird Installation ansible.windows.win_package: path: C:\Program Files\Netbird\netbird_uninstall.exe product_id: Netbird arguments: /S state: absent wait_for_children: true chdir: C:\Program Files\Netbird ignore_errors: yes - name: Install Netbird MSI ansible.windows.win_package: path: C:\Windows\Temp\netbird_installer.exe product_id: Netbird arguments: /S state: present wait_for_children: true ignore_errors: yes - name: Start Netbird service win_service: name: Netbird state: started - name: Run Netbird enrollment win_shell: | & "C:\Program Files\Netbird\netbird.exe" up --setup-key MY_ENROLLMENT_KEY register: netbird_setup ignore_errors: yes - name: Verify Netbird version win_shell: | netbird version register: netbird_version - debug: var=netbird_version.stdout_lines - name: Delete Netbird installer win_file: path: C:\Windows\Temp\netbird_installer.exe state: absent ```
Author
Owner

@b00nish commented on GitHub (Jan 28, 2025):

After a lot of trial and error, this playbook works.

Thanks for your work.

A question: is there a reason why the update must be done as an uninstall with subsequent reinstall and reenrollment?

My experience with the GUI installer on windows is that the new installer auto-uninstalls the old version, installs the new version and keeps the enrollment/settings.

Can't this behaviour be emulated with the silent command line install? So we could get rid of the enrollment key for devices that are already enrolled anyway.

<!-- gh-comment-id:2619126403 --> @b00nish commented on GitHub (Jan 28, 2025): > After a lot of trial and error, this playbook works. Thanks for your work. A question: is there a reason why the update must be done as an uninstall with subsequent reinstall and reenrollment? My experience with the GUI installer on windows is that the new installer auto-uninstalls the old version, installs the new version and keeps the enrollment/settings. Can't this behaviour be emulated with the silent command line install? So we could get rid of the enrollment key for devices that are already enrolled anyway.
Author
Owner

@dannykorpan commented on GitHub (Jan 29, 2025):

I don't know, you have to try it.

<!-- gh-comment-id:2621722289 --> @dannykorpan commented on GitHub (Jan 29, 2025): I don't know, you have to try it.
Author
Owner

@jbleeker-ops commented on GitHub (Jul 13, 2026):

After a lot of trial and error, this playbook works.

Thanks for your work.

A question: is there a reason why the update must be done as an uninstall with subsequent reinstall and reenrollment?

My experience with the GUI installer on windows is that the new installer auto-uninstalls the old version, installs the new version and keeps the enrollment/settings.

Can't this behaviour be emulated with the silent command line install? So we could get rid of the enrollment key for devices that are already enrolled anyway.

Were you ever able to figure out if it was possible to emulate the GUI upgrade via cli?

<!-- gh-comment-id:4958929731 --> @jbleeker-ops commented on GitHub (Jul 13, 2026): > > After a lot of trial and error, this playbook works. > > Thanks for your work. > > A question: is there a reason why the update must be done as an uninstall with subsequent reinstall and reenrollment? > > My experience with the GUI installer on windows is that the new installer auto-uninstalls the old version, installs the new version and keeps the enrollment/settings. > > Can't this behaviour be emulated with the silent command line install? So we could get rid of the enrollment key for devices that are already enrolled anyway. Were you ever able to figure out if it was possible to emulate the GUI upgrade via cli?
Sign in to join this conversation.
No Label triage-needed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#4269