---
- name: Copy dotNET 3.5 CAB File to Server and Troubleshoot
hosts: your_target_host
tasks:
- name: Check if Mapped Drive Exists
win_shell: dir Z:
register: mapped_drive_status
ignore_errors: yes # Ignore errors, we just want to check if drive is accessible
- name: Debug Mapped Drive Status
debug:
var: mapped_drive_status
- name: Use UNC Path if Mapped Drive is Unavailable
set_fact:
use_unc_path: "{{ 'false' if mapped_drive_status.failed else 'true' }}"
- name: Copy dotNET 3.5 CAB File to Server using UNC Path
win_copy:
src: "\\{{ storage_account_name }}.
file.core.windows.net\share\Software\Microsoft\dotNET3\microsoft-windows-netfx3.cab"
dest: "{{ Generic_Temp_Path }}\\dotNET53"
when: use_unc_path == 'true'
- name: Check File Existence on Mapped Drive
win_stat:
path: "Z:\\Software\\Microsoft\\dotNET3\\microsoft-windows-netfx3.cab"
register: file_status
- name: Display File Status on Mapped Drive
debug:
var: file_status
- name: Copy dotNET 3.5 CAB File to Server using Mapped Drive
win_copy:
src: "Z:\\Software\\Microsoft\\dotNET3\\microsoft-windows-netfx3.cab"
dest: "{{ Generic_Temp_Path }}\\dotNET53"
when: file_status.stat.exists
- name: Display Debug Information
debug:
msg: "UNC Path: {{ use_unc_path }} | File Exists: {{ file_status.stat.exists }}"