我在使用 ansible 安装驱动器时遇到 "Not a directory" 错误
I am getting a "Not a directory" error mounting a drive using ansible
我正在尝试使用 ansible 安装驱动器。这是我的剧本
- 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
当我 运行 它时,前 2 个任务完成。创建目录并创建文件系统。但是,当我进行到最后一步时出现以下错误:
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"}
关于造成这种情况的原因有什么想法吗?
好的,我解决了问题。我认为主要问题是 opts 参数,我将其更改为 defaults,nofail 并且它起作用了。所以剧本现在看起来像这样:
- 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
我正在尝试使用 ansible 安装驱动器。这是我的剧本
- 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
当我 运行 它时,前 2 个任务完成。创建目录并创建文件系统。但是,当我进行到最后一步时出现以下错误:
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"}
关于造成这种情况的原因有什么想法吗?
好的,我解决了问题。我认为主要问题是 opts 参数,我将其更改为 defaults,nofail 并且它起作用了。所以剧本现在看起来像这样:
- 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