Обновить playbooks/install_software_win.yml

This commit is contained in:
ogrechko committed 2026-10-02 12:32:12 +03:00
1 parent 7d60f3bc2f
commit 39bf3d0f83
1 file changed
+21 -27
+21 -27
View File
@@ -11,6 +11,8 @@
ansible_port: "{{ winrm_port | default(5985) }}" ansible_port: "{{ winrm_port | default(5985) }}"
ansible_winrm_transport: "{{ winrm_transport | default('ntlm') }}" ansible_winrm_transport: "{{ winrm_transport | default('ntlm') }}"
ansible_winrm_server_cert_validation: ignore ansible_winrm_server_cert_validation: ignore
ansible_winrm_read_timeout_sec: 600
ansible_winrm_operation_timeout_sec: 580
ansible_user: "{{ win_user }}" ansible_user: "{{ win_user }}"
ansible_password: "{{ win_pass }}" ansible_password: "{{ win_pass }}"
@@ -19,11 +21,27 @@
gather_facts: no gather_facts: no
vars: vars:
installer_args: "/S"
local_dir: 'C:\Windows\Temp\ansible_install' local_dir: 'C:\Windows\Temp\ansible_install'
local_file: "{{ local_dir }}\\{{ installer_file }}" local_file: "{{ local_dir }}\\{{ installer_file }}"
install_dir: 'C:\Program Files\FreeCAD 1.1'
tasks: 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 - name: Copy installer from share to local temp
ansible.windows.win_powershell: ansible.windows.win_powershell:
parameters: parameters:
@@ -62,41 +80,17 @@
changed_when: false changed_when: false
failed_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 - name: Fail if copy did not succeed
ansible.builtin.fail: ansible.builtin.fail:
msg: "Не удалось скопировать {{ installer_file }}: {{ copy_result.result.error | default('неизвестная ошибка') }}" msg: "Не удалось скопировать {{ installer_file }}: {{ copy_result.result.error | default('неизвестная ошибка') }}"
when: not (copy_result.result.copied | default(false)) 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 - name: Install and clean up
block: block:
- name: Install {{ installer_file }} - 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: args:
creates: 'C:\Program Files\FreeCAD 1.1\bin\FreeCAD.exe' creates: '{{ install_dir }}\bin\FreeCAD.exe'
register: inst register: inst
failed_when: inst.rc not in [0, 3010] failed_when: inst.rc not in [0, 3010]
always: always: