Open dannykorpan opened 4 weeks ago
Have you tried with the msi package as well? That one should work with an unattended install
The first enrollment was done via the exe.
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
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:
Thank you in advance for any help, Danny