I am unable to use Ansible localhost
(Linux) to connect to a shared folder on a Windows Server.
I am getting [Errno 2] No such file or directory: b'net'
. However, I have checked that my file path to the shared folder is correct, so I am not sure how to resolve this error.
The shared folder task as written in my playbook:
- name: Connect to shared folder
command: net use * '\\10.15.250.110\mixeddocs' /user:{{ username }} {{ password }} /p:no
become: yes
The full error message:
The full traceback is:
File "/tmp/ansible_ansible.legacy.command_payload_tjjro3uh/ansible_ansible.legacy.command_payload.zip/ansible/module_utils/basic.py", line 2022, in run_command
cmd = subprocess.Popen(args, **kwargs)
File "/usr/lib64/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib64/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
fatal: [localhost]: FAILED! => {
"changed": false,
"cmd": "net use '*' '\\\\10.15.250.110\\mixeddocs' /user:newuser Password /p:no",
"invocation": {
"module_args": {
"_raw_params": "net use * '\\\\10.15.250.110\\mixeddocs' /user:newuser Password /p:no",
"_uses_shell": false,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": false
}
},
"msg": "[Errno 2] No such file or directory: b'net'",
"rc": 2,
"stderr": "",
"stderr_lines": [],
"stdout": "",
"stdout_lines": []
}