Обновить 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:
|
tasks:
|
||||||
- name: Check running FreeCAD
|
- name: Check running FreeCAD
|
||||||
ansible.windows.win_shell: |
|
ansible.windows.win_powershell:
|
||||||
Get-Process FreeCAD -IncludeUserName -ErrorAction SilentlyContinue |
|
script: |
|
||||||
ForEach-Object { "$($_.UserName) (session $($_.SessionId))" }
|
$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
|
register: running
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Fail if FreeCAD is running
|
- name: Fail if FreeCAD is running
|
||||||
ansible.builtin.fail:
|
ansible.builtin.fail:
|
||||||
msg: "FreeCAD запущен у: {{ running.stdout_lines | join(', ') }}. Закройте его или включите force_close."
|
msg: "FreeCAD запущен у: {{ running.result | join(', ') }}. Закройте его или включите force_close."
|
||||||
when: running.stdout_lines | length > 0 and not (force_close | default(false) | bool)
|
when: running.result | length > 0 and not (force_close | default(false) | bool)
|
||||||
|
|
||||||
- name: Force close FreeCAD
|
- name: Force close FreeCAD
|
||||||
ansible.windows.win_shell: Stop-Process -Name FreeCAD -Force
|
ansible.windows.win_shell: Stop-Process -Name FreeCAD -Force -ErrorAction SilentlyContinue; exit 0
|
||||||
when: running.stdout_lines | length > 0 and (force_close | default(false) | bool)
|
when: running.result | length > 0 and (force_close | default(false) | bool)
|
||||||
|
|
||||||
- name: Copy installer from share to local temp
|
- name: Copy installer from share to local temp
|
||||||
ansible.windows.win_powershell:
|
ansible.windows.win_powershell:
|
||||||
|
|||||||
Reference in new issue
Block a user