From 39bf3d0f83affe2288d26d8c79c6e55c3b95e366 Mon Sep 17 00:00:00 2001 From: ogrechko Date: Fri, 2 Oct 2026 12:32:12 +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 | 48 +++++++++++++----------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/playbooks/install_software_win.yml b/playbooks/install_software_win.yml index e515f01..105c3c9 100644 --- a/playbooks/install_software_win.yml +++ b/playbooks/install_software_win.yml @@ -11,6 +11,8 @@ ansible_port: "{{ winrm_port | default(5985) }}" ansible_winrm_transport: "{{ winrm_transport | default('ntlm') }}" ansible_winrm_server_cert_validation: ignore + ansible_winrm_read_timeout_sec: 600 + ansible_winrm_operation_timeout_sec: 580 ansible_user: "{{ win_user }}" ansible_password: "{{ win_pass }}" @@ -19,11 +21,27 @@ gather_facts: no vars: - installer_args: "/S" local_dir: 'C:\Windows\Temp\ansible_install' local_file: "{{ local_dir }}\\{{ installer_file }}" + install_dir: 'C:\Program Files\FreeCAD 1.1' tasks: + - name: Check running FreeCAD + ansible.windows.win_shell: | + Get-Process FreeCAD -IncludeUserName -ErrorAction SilentlyContinue | + ForEach-Object { "$($_.UserName) (session $($_.SessionId))" } + 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) + + - 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) + - name: Copy installer from share to local temp ansible.windows.win_powershell: parameters: @@ -62,41 +80,17 @@ changed_when: false failed_when: false - - name: Show copy result - ansible.builtin.debug: - msg: - error: "{{ copy_result.result.error | default(copy_result.msg | default('нет данных')) }}" - files: "{{ copy_result.result.files | default([]) }}" - - name: Fail if copy did not succeed ansible.builtin.fail: msg: "Не удалось скопировать {{ installer_file }}: {{ copy_result.result.error | default('неизвестная ошибка') }}" when: not (copy_result.result.copied | default(false)) - - name: Install and clean up - block: - - name: Check running FreeCAD - ansible.windows.win_shell: | - Get-Process FreeCAD -IncludeUserName -ErrorAction SilentlyContinue | - ForEach-Object { "$($_.UserName) (session $($_.SessionId))" } - 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) - - - 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) - - name: Install and clean up block: - name: Install {{ installer_file }} - ansible.windows.win_command: '"{{ local_file }}" /S /D=C:\Program Files\FreeCAD 1.1' + ansible.windows.win_command: '"{{ local_file }}" /S /D={{ install_dir }}' args: - creates: 'C:\Program Files\FreeCAD 1.1\bin\FreeCAD.exe' + creates: '{{ install_dir }}\bin\FreeCAD.exe' register: inst failed_when: inst.rc not in [0, 3010] always: