python-3.x - 如何使用 ansible playbooks 卸载 NFS 文件系统
问题描述
我正在尝试使用 ansible 卸载 nfs 文件系统。我正在使用以下代码-
---
- name: first playbook
hosts: localhost
become: yes
vars:
path: "{{ path | mandatory }}"
tasks:
- name: unmount nfs
mount:
state: unmounted
path: "path_of_nfs_filesystem"
register: result
- debug:
var=result.stdout
但是上面的代码并没有卸载。结果的输出是 "Variable is undefined" 。我也使用了单独的调试任务。我已根据最新更改修改了问题中的代码。请建议对我的代码进行一些更改。我对ansible剧本很陌生
解决方案
我发现这是我问题的解决方案。我希望这对其他人也有帮助
- name: Unmount a mounted volume
mount:
path: /tmp/mnt-pnt
state: unmounted
register: result
retries: 5
delay: 60
until: result is not failed
- debug:
var: result
重试和延迟是在挂载点忙且无法卸载时,在 60 秒的等待时间内最多重试 5 次
推荐阅读
- android - 如何在滚动视图中正确制作垂直回收器视图,不会减慢片段的出现速度?
- python - 用另一个数据帧中的干净 str 替换混乱的 str
- conda - 如何打印特定已安装的 conda 包版本号退出?
- java - 正则表达式在特定字符串中查找 .exe 扩展名。?
- swift - 以编程方式重新定位 UIButton
- r - 某些数据大小小于 2 的数据列表中的 sample_n(2, replace=F) 存在问题
- android - Flutter - 如何使用无代码设置连接到 Facebook 的 SDK 应用程序事件
- java - JUnit 5 中多个扩展的顺序
- node.js - NodeJS、DiscordJS 命令参数由 {} 拆分
- macos - 如何将静态库嵌入到共享库中 - 在 OSX 上