diff --git a/plugins/modules/win_mapped_drive.py b/plugins/modules/win_mapped_drive.py index 75a7eb2a..6fadcbda 100644 --- a/plugins/modules/win_mapped_drive.py +++ b/plugins/modules/win_mapped_drive.py @@ -22,7 +22,7 @@ description: - The password for C(username) that is used when testing the initial connection. - - This is never saved with a mapped drive, use the M(community.windows.win_credential) module + - This is never saved with a mapped drive, use the M(ansible.windows.win_credential) module to persist a username and password for a host. type: str path: @@ -50,12 +50,12 @@ username: description: - The username that is used when testing the initial connection. - - This is never saved with a mapped drive, the M(community.windows.win_credential) module + - This is never saved with a mapped drive, the M(ansible.windows.win_credential) module to persist a username and password for a host. - This is required if the mapped drive requires authentication with custom credentials and become, or CredSSP cannot be used. - If become or CredSSP is used, any credentials saved with - M(community.windows.win_credential) will automatically be used instead. + M(ansible.windows.win_credential) will automatically be used instead. type: str notes: - You cannot use this module to access a mapped drive in another Ansible task, @@ -73,24 +73,24 @@ Windows Server hosts need to install the C(WebDAV-Redirector) feature using M(ansible.windows.win_feature). seealso: -- module: community.windows.win_credential +- module: ansible.windows.win_credential author: - Jordan Borean (@jborean93) ''' EXAMPLES = r''' - name: Create a mapped drive under Z - community.windows.win_mapped_drive: + ansible.windows.win_mapped_drive: letter: Z path: \\domain\appdata\accounting - name: Delete any mapped drives under Z - community.windows.win_mapped_drive: + ansible.windows.win_mapped_drive: letter: Z state: absent - name: Only delete the mapped drive Z if the paths match (error is thrown otherwise) - community.windows.win_mapped_drive: + ansible.windows.win_mapped_drive: letter: Z path: \\domain\appdata\accounting state: absent @@ -98,7 +98,7 @@ - name: Create mapped drive with credentials and save the username and password block: - name: Save the network credentials required for the mapped drive - community.windows.win_credential: + ansible.windows.win_credential: name: server type: domain_password username: username@DOMAIN @@ -106,7 +106,7 @@ state: present - name: Create a mapped drive that requires authentication - community.windows.win_mapped_drive: + ansible.windows.win_mapped_drive: letter: M path: \\SERVER\C$ state: present @@ -118,7 +118,7 @@ ansible_become_pass: '{{ ansible_password }}' - name: Create mapped drive with credentials that do not persist on the next logon - community.windows.win_mapped_drive: + ansible.windows.win_mapped_drive: letter: M path: \\SERVER\C$ state: present @@ -137,7 +137,7 @@ when: webdav_feature.reboot_required - name: Map the HTTPS WebDAV location - community.windows.win_mapped_drive: + ansible.windows.win_mapped_drive: letter: W path: \\live.sysinternals.com@SSL\tools # https://live.sysinternals.com/tools state: present diff --git a/tests/integration/targets/win_mapped_drive/tasks/tests.yml b/tests/integration/targets/win_mapped_drive/tasks/tests.yml index a7d47ca2..134a20d9 100644 --- a/tests/integration/targets/win_mapped_drive/tasks/tests.yml +++ b/tests/integration/targets/win_mapped_drive/tasks/tests.yml @@ -51,12 +51,16 @@ ansible.windows.win_command: 'net use {{test_win_mapped_drive_letter}}:' register: create_drive_actual +- name: Set expected remote path + set_fact: + expected_remote: "Remote name \\\\{{ ansible_hostname }}\\{{ test_win_mapped_drive_path }}" + - name: assert create mapped drive assert: that: - create_drive is changed - create_drive_actual.rc == 0 - - create_drive_actual.stdout_lines[1] == "Remote name \\\\{{ansible_hostname}}\\{{test_win_mapped_drive_path}}" + - create_drive_actual.stdout_lines[1] == expected_remote - name: create mapped drive again win_mapped_drive: @@ -87,7 +91,7 @@ that: - change_drive_target_check is changed - change_drive_target_actual_check.rc == 0 - - change_drive_target_actual_check.stdout_lines[1] == "Remote name \\\\{{ansible_hostname}}\\{{test_win_mapped_drive_path}}" + - change_drive_target_actual_check.stdout_lines[1] == expected_remote - name: change mapped drive target win_mapped_drive: @@ -100,12 +104,16 @@ ansible.windows.win_command: 'net use {{test_win_mapped_drive_letter}}:' register: change_drive_target_actual +- name: Set expected remote path + set_fact: + expected_remote2: "Remote name \\\\{{ ansible_hostname }}\\{{ test_win_mapped_drive_path2 }}" + - name: assert change mapped drive target assert: that: - change_drive_target is changed - change_drive_target_actual.rc == 0 - - change_drive_target_actual.stdout_lines[1] == "Remote name \\\\{{ansible_hostname}}\\{{test_win_mapped_drive_path2}}" + - change_drive_target_actual.stdout_lines[1] == expected_remote2 - name: fail to delete mapped drive if target doesn't match win_mapped_drive: @@ -132,7 +140,7 @@ that: - delete_drive_check is changed - delete_drive_actual_check.rc == 0 - - delete_drive_actual_check.stdout_lines[1] == "Remote name \\\\{{ansible_hostname}}\\{{test_win_mapped_drive_path2}}" + - delete_drive_actual_check.stdout_lines[1] == expected_remote2 - name: delete mapped drive win_mapped_drive: