I am trying to mount a drive using ansible. Here is my playbook
- name: Create directory
file:
path: /u01
state: directory
- name: Create a filesystem on a drive
filesystem:
fstype: xfs
dev: /dev/xvdf
- name: Mount the drive and update the fstab file
mount:
backup: yes
path: /u01
src: /dev/xvdf
opts: bind
state: mounted
fstype: xfs
When I run it, the first 2 ntasks get completed. A directory is created and a filesystem is also created. However, I get the following error when I get to the final step:
TASK [mount : Mount the drive and update the fstab file] ****************************************************************************************************
fatal: [172.31.42.187]: FAILED! => {"changed": false, "msg": "Error mounting /u01: mount: /u01: mount(2) system call failed: Not a directory.\n"}
Any ideas as to what is causing this?
Ok, I solved the problem. I thnk the main issue was with the opts parameter, I changed it to defaults,nofail and it worked. So the playbook now looks like this:
- name: Create a filesystem on a drive
filesystem:
fstype: xfs
dev: /dev/xvdb
- name: Mount the drive and update the fstab file
mount:
backup: yes
path: "/u01"
src: /dev/xvdb
opts: defaults,nofail
state: mounted
fstype: xfs