Обновить playbooks/install_software_win.yml
This commit is contained in:
1 parent
39bf3d0f83
commit
bcea6d7296
1 file changed
+13
-7
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user