windowspowershellansiblesubst

Ansible to SUBST a drive machine-wide


I've set up Ansible to connect to a Windows Server 2019 using WinRM certificate method. I need to map D drive to simply mirror C. With SUBST I can do SUBST D: C:\ but...

How can I map C to D machine-wide using an Ansible playbook?


Solution

  • The registry value for the drive was missing \??\ prefix. Everything works correctly with the right registry value. For the record, this is the ansible task I ended up with:

        - name: Map D drive to C.
          ansible.windows.win_regedit:
            path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices
            name: "D:"
            state: present
            type: string
            data: '\??\C:'