ansible - 为什么我的 nfs4 挂载不能与 ansible 一起使用?
问题描述
使用 Ansible,我无法挂载 nfs4。
我在服务器上配置了 nfs4 导出,我可以使用 bash shell 安装 nfs4 和 nfs。
我也可以让 nfs 在 ansible 中工作,而不是在 nfs4 中工作。
所以我想知道如何将服务器上的 /pool1/volume1 之类的共享安装到客户端上的相同样式路径- /pool1/volume1
尝试切换到有效的标准 nfs,我可以在 bash shell 中安装 nfs4,但不能使用 ansible
这有效-
- name: mount softnas NFS volume
become: yes
mount:
fstype: nfs
path: "/pool1/volume1"
opts: rsize=8192,wsize=8192,timeo=14,intr,_netdev
src: "10.0.11.11:/pool1/volume1"
state: mounted
但这并不
- name: mount softnas NFS volume
become: yes
mount:
fstype: nfs4
path: "/pool1/volume1"
opts: rsize=8192,wsize=8192,timeo=14,intr,_netdev
src: "10.0.11.11:/pool1/volume1"
state: mounted
如果我在 shell 中使用这个命令,这在将路径安装到测试中效果很好。sudo mount -t nfs4 10.0.11.11:/ /test 虽然它不太正确,因为像 /pool1/volume1 和 /pool2/volume2 这样的 id 不会出现在 /test 下
我在服务器上的导出文件是这个-
/ *(ro,fsid=0)
# These mounts are managed in ansible playbook softnas-ebs-disk-update-exports.yaml
# BEGIN ANSIBLE MANAGED BLOCK /pool1/volume1/
/pool1/volume1/ *(async,insecure,no_subtree_check,no_root_squash,rw,nohide)
# END ANSIBLE MANAGED BLOCK /pool1/volume1/
# BEGIN ANSIBLE MANAGED BLOCK /pool2/volume2/
/pool2/volume2/ *(async,insecure,no_subtree_check,no_root_squash,rw,nohide)
# END ANSIBLE MANAGED BLOCK /pool2/volume2/
当我尝试切换到 nfs4 时,我用 ansible 收到此错误
安装 /pool1/volume1/ 时出错:mount.nfs4:安装 10.0.11.11:/pool1/volume1/ 失败,服务器给出的原因:没有这样的文件或目录
解决方案
检查挂载点是否存在
mkdir /pool1/volume1 # if not exists. Or create an ansible task to create the directory
更新为随着份额的变化而变化 /
- name: mount softnas NFS volume
become: yes
mount:
fstype: nfs4
path: "/pool1/volume1"
opts: rsize=8192,wsize=8192,timeo=14,intr,_netdev
src: "10.0.11.11:/"
state: mounted
如果不想挂载/,则在服务器中共享/pool1/volume1。
推荐阅读
- android - 如何从数组编辑文本中获取字符串
- c++ - 为什么会出现分段错误
- javascript - 对 Spring Boot Endpoint 的 Ajax 请求读取 HTTP MSG 失败
- vba - 编辑自动转发的电子邮件以在开始时删除行
- javascript - 如何上传项目中但不属于 Firebase 存储输入的图像?
- ruby-on-rails - 如何使用 Nokogiri 将具有名称空间的节点树插入现有 XML 文件?
- java - 它是一个简单的 Java HashMap,如何在各个存储桶中添加元素
- spring-boot - 如何生成 Map 类型的 RequestBody
使用springdoc swagger open api 3.0? - vb.net - Win10程序上的VB .Net无法运行
- r - 使用具有多个条件的 if 语句替换数据帧中的因子时出现问题(R)