From 19aead426e33d9f77abe5d5ff9abd96503b4752e Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Thu, 2 Apr 2026 16:38:57 +0200 Subject: [PATCH] Install WhatsApp from Microsoft Store on Windows --- .../group_vars/workstation_host_windows.yml | 3 +++ .../tasks/main.yml | 27 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ansible/inventory/group_vars/workstation_host_windows.yml b/ansible/inventory/group_vars/workstation_host_windows.yml index 4c94112..053769d 100644 --- a/ansible/inventory/group_vars/workstation_host_windows.yml +++ b/ansible/inventory/group_vars/workstation_host_windows.yml @@ -31,6 +31,9 @@ windows_winget_packages: name: Postman - id: Telegram.TelegramDesktop name: Telegram Desktop + - id: 9NKSQGP7F2NH + name: WhatsApp + source: msstore windows_vscode_extensions: - ms-vscode-remote.remote-containers diff --git a/ansible/roles/profile_workstation_host_windows/tasks/main.yml b/ansible/roles/profile_workstation_host_windows/tasks/main.yml index 437a279..5de5c71 100644 --- a/ansible/roles/profile_workstation_host_windows/tasks/main.yml +++ b/ansible/roles/profile_workstation_host_windows/tasks/main.yml @@ -128,13 +128,36 @@ script: | $packageId = '{{ item.id }}' $packageName = '{{ item.name | default(item.id) }}' - $installed = & winget list --id $packageId --exact --accept-source-agreements --disable-interactivity 2>$null + $packageSource = '{{ item.source | default('') }}' + $listArgs = @( + 'list' + '--id', $packageId + '--exact' + '--accept-source-agreements' + '--disable-interactivity' + ) + $installArgs = @( + 'install' + '--id', $packageId + '--exact' + '--silent' + '--accept-package-agreements' + '--accept-source-agreements' + '--disable-interactivity' + ) + + if (-not [string]::IsNullOrWhiteSpace($packageSource)) { + $listArgs += @('--source', $packageSource) + $installArgs += @('--source', $packageSource) + } + + $installed = & winget @listArgs 2>$null if ($LASTEXITCODE -eq 0 -and $installed -match [regex]::Escape($packageId)) { $Ansible.Changed = $false return } - & winget install --id $packageId --exact --silent --accept-package-agreements --accept-source-agreements --disable-interactivity + & winget @installArgs if ($LASTEXITCODE -ne 0) { throw "Failed to install $packageName with winget" }