问题
I am trying to mount a remote directory. Following is the code:
- name: mount the folder.
mount: name=/mnt/point src="//sdfs601/master.src/scm/pkgs" fstype=auto opts="domain=td,username=uname,password=pass,file_mode=0777,dir_mode=0777" state=mounted
But it is giving the following error:
fatal: [153.64.221.181]: FAILED! => {"changed": false, "failed": true, "msg": "Error mounting /mnt/15.00: mount: special device //sdfs601/master.src/scm/pkgs does not exist\n"}
But when i try mounting using the shell command on target host. It is working fine. Following is the command:
/bin/mount -o username=uname,password=pass,domain=dd //sdfs601/master.src/scm/pkgs /mnt/point
回答1:
http://docs.ansible.com/ansible/mount_module.html
This module controls active and configured mount points in /etc/fstab. You can check python code https://github.com/ansible/ansible-modules-core/blob/devel/system/mount.py#L219
Please check your /etc/fstab and add an appropriate record.
回答2:
For future folks who are getting the same error, set the appropriate fstype
.
I got the exact same error message when I was trying to do something similar, mounting an NFS share. It also worked fine in shell. But then it worked after setting fstype: nfs
in the Ansible task.
Got the clue from here: Why won't Ansible mount Vagrant remote NFS share
来源:https://stackoverflow.com/questions/35449311/error-in-mount-module-in-ansible