Reputation: 623
I'm trying to get ansible to mount my attached and formatted hard drive located under /dev/vdb/
to /data
. This is the playbook section:
---
- name: setup dada2
hosts: tnt
remote_user: ubuntu
become: yes
become_method: sudo
tasks:
- name: Create the file system
filesystem:
fstype: ext4
dev: /dev/vdb
- name: Mount the created filesystem
mount:
path: /data
src: /dev/vdb/
fstype: ext4
state: mounted
- name: Make /data available for everyone
file:
path: /data
state: directory
mode: 0775
However, I get the error message:
TASK [Mount the created filesystem] ********************************************
fatal: [x.x.x.x]: FAILED! => {"changed": false, "msg": "Error mounting /data: mount: /data: special device /dev/vdb/ does not exist (a path prefix is not a directory).\n"}
but /dev/vdb
does exist and running sudo mount /dev/vdb /data
works fine. Any ideas what could be the reason for this? I have no experience with /etc/fstab
, but the name occured often so I had a look into it. It says:
LABEL=cloudimg-rootfs / ext4 defaults 0 0
LABEL=UEFI /boot/efi vfat defaults 0 0
/dev/vdb/ /data ext4 defaults 0 0
Any ideas on this one?
EDIT:
A similar error was described here: Error in Mount Module in Ansible, but I set the fstype as suggested and I would not know what entry I would have to add to fstab and how?
Upvotes: 0
Views: 1482
Reputation: 68024
The problem is the trailing slash in /dev/vdb/
- name: Mount the created filesystem
mount:
path: /data
src: /dev/vdb/
fstype: ext4
state: mounted
Correct
- name: Mount the created filesystem
mount:
path: /data
src: /dev/vdb
fstype: ext4
state: mounted
Remove the line from /etc/fstab manually
/dev/vdb/ /data ext4 defaults 0 0
Upvotes: 1