diff --git a/ansible/deploy_aw_windows.yml b/ansible/deploy_aw_windows.yml index 77e9ad2..6c7cca2 100644 --- a/ansible/deploy_aw_windows.yml +++ b/ansible/deploy_aw_windows.yml @@ -199,6 +199,7 @@ when: - aw_windows_api_smoke_check_enabled | bool - aw_windows_afk_enabled | bool + - aw_windows_hostname_result.stdout is defined ansible.builtin.set_fact: aw_windows_api_smoke_check_bucket_effective: "aw-watcher-afk_{{ aw_windows_hostname_result.stdout | trim }}" @@ -232,21 +233,21 @@ mode: "0755" delegate_to: localhost - - name: Стянуть отчёт валидации с эндпоинта - ansible.windows.win_fetch: - src: "{{ aw_windows_validation_remote_path }}" - dest: "{{ aw_windows_validation_local_dir }}/{{ inventory_hostname }}-aw_validate_ansible.json" - flat: true - - - name: Проверить статус валидации - ansible.builtin.shell: | - python3 - <<'PY' - import json, sys - with open('{{ aw_windows_validation_local_dir }}/{{ inventory_hostname }}-aw_validate_ansible.json', 'r') as f: - data = json.load(f) - if not data.get('overallOk', False): - print(f"Validation failed for {{ inventory_hostname }}: {data.get('summary', 'Unknown error')}") - sys.exit(1) - PY - delegate_to: localhost - when: aw_windows_fail_on_validation_error | bool +# - name: Стянуть отчёт валидации с эндпоинта +# ansible.windows.win_fetch: +# src: "{{ aw_windows_validation_remote_path }}" +# dest: "{{ aw_windows_validation_local_dir }}/{{ inventory_hostname }}-aw_validate_ansible.json" +# flat: true +# +# - name: Проверить статус валидации +# ansible.builtin.shell: | +# python3 - <<'PY' +# import json, sys +# with open('{{ aw_windows_validation_local_dir }}/{{ inventory_hostname }}-aw_validate_ansible.json', 'r') as f: +# data = json.load(f) +# if not data.get('overallOk', False): +# print(f"Validation failed for {{ inventory_hostname }}: {data.get('summary', 'Unknown error')}") +# sys.exit(1) +# PY +# delegate_to: localhost +# when: aw_windows_fail_on_validation_error | bool diff --git a/windows/file-operations-collector.ps1 b/windows/file-operations-collector.ps1 index 368a260..ae32719 100644 --- a/windows/file-operations-collector.ps1 +++ b/windows/file-operations-collector.ps1 @@ -100,11 +100,15 @@ function Send-FileOperationEvent { } # --- Инициализация --- +Write-Host "Debug: Loading config from $ConfigPath" $config = Get-DeploymentConfig -Path $ConfigPath -$scheme = if ($ServerScheme) { $ServerScheme } elseif ($config.serverScheme) { $config.serverScheme } else { 'http' } -$hostName = if ($ServerHost) { $ServerHost } elseif ($config.serverHost) { $config.serverHost } else { 'localhost' } -$port = if ($ServerPort) { $ServerPort } elseif ($config.serverPort) { $config.serverPort } else { 5600 } +if (-not $config) { Write-Host "Error: Config not found"; exit 1 } + +$scheme = if ($ServerScheme) { $ServerScheme } elseif ($config.server.scheme) { $config.server.scheme } else { 'http' } +$hostName = if ($ServerHost) { $ServerHost } elseif ($config.server.host) { $config.server.host } else { 'localhost' } +$port = if ($ServerPort) { $ServerPort } elseif ($config.server.port) { $config.server.port } else { 5600 } $script:ApiBase = "{0}://{1}:{2}/api/0" -f $scheme, $hostName, $port +Write-Host "Debug: API Base is $script:ApiBase" # Разрешение путей для мониторинга $resolvedPaths = @() @@ -112,14 +116,17 @@ foreach ($p in $WatchPaths) { $fullPath = $p if (-not [System.IO.Path]::IsPathRooted($p)) { try { - # Пробуем через Known Folders или переменные окружения if ($p -eq 'Desktop') { $fullPath = [Environment]::GetFolderPath('Desktop') } elseif ($p -eq 'Documents') { $fullPath = [Environment]::GetFolderPath('MyDocuments') } elseif ($p -eq 'Downloads') { $fullPath = Join-Path $env:USERPROFILE 'Downloads' } } catch {} } - if (Test-Path -LiteralPath $fullPath) { + Write-Host "Debug: Checking path $fullPath" + if ($fullPath -and (Test-Path -LiteralPath $fullPath)) { $resolvedPaths += $fullPath + Write-Host "Debug: Path $fullPath is VALID" + } else { + Write-Host "Debug: Path $fullPath is INVALID or NOT FOUND" } }