From bcea6d7296eb847d555868d6bde4ce708042a4c4 Mon Sep 17 00:00:00 2001 From: ogrechko Date: Fri, 2 Oct 2026 12:35:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20playbooks/install=5Fsoftware=5Fwin.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playbooks/install_software_win.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/playbooks/install_software_win.yml b/playbooks/install_software_win.yml index 105c3c9..da97cf6 100644 --- a/playbooks/install_software_win.yml +++ b/playbooks/install_software_win.yml @@ -27,20 +27,26 @@ tasks: - name: Check running FreeCAD - ansible.windows.win_shell: | - Get-Process FreeCAD -IncludeUserName -ErrorAction SilentlyContinue | - ForEach-Object { "$($_.UserName) (session $($_.SessionId))" } + ansible.windows.win_powershell: + script: | + $Ansible.Failed = $false + $list = @(Get-CimInstance Win32_Process -Filter "Name = 'FreeCAD.exe'" -ErrorAction SilentlyContinue | + ForEach-Object { + $o = Invoke-CimMethod -InputObject $_ -MethodName GetOwner -ErrorAction SilentlyContinue + "$($o.Domain)\$($o.User) (session $($_.SessionId))" + }) + $Ansible.Result = $list register: running changed_when: false - name: Fail if FreeCAD is running ansible.builtin.fail: - msg: "FreeCAD запущен у: {{ running.stdout_lines | join(', ') }}. Закройте его или включите force_close." - when: running.stdout_lines | length > 0 and not (force_close | default(false) | bool) + msg: "FreeCAD запущен у: {{ running.result | join(', ') }}. Закройте его или включите force_close." + when: running.result | length > 0 and not (force_close | default(false) | bool) - name: Force close FreeCAD - ansible.windows.win_shell: Stop-Process -Name FreeCAD -Force - when: running.stdout_lines | length > 0 and (force_close | default(false) | bool) + ansible.windows.win_shell: Stop-Process -Name FreeCAD -Force -ErrorAction SilentlyContinue; exit 0 + when: running.result | length > 0 and (force_close | default(false) | bool) - name: Copy installer from share to local temp ansible.windows.win_powershell: