我在使用ansible装入驱动器时遇到“非目录”错误

问题描述 投票:0回答:1

我正在尝试使用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

当我运行它时,前两个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"}

关于什么原因的任何想法?

linux ubuntu ansible devops mount
1个回答
0
投票

好,我解决了这个问题。我认为主要问题在于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
© www.soinside.com 2019 - 2024. All rights reserved.