繁体   English   中英

使用 ansible 安装驱动器时出现“不是目录”错误

[英]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 个 ntasks 完成。 创建一个目录并创建一个文件系统。 但是,当我进入最后一步时,出现以下错误:

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 参数,我将其更改为默认值,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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM