在使用 Ansible 的 lineinfile
模块将多个挂载点添加到 /etc/fstab
之后,我想运行一个简单的 mount -a
使这些生效。
它确实适用于
- name: mount all
command: mount -a
become: true
然而ansible坚持建议使用mount
模块
[WARNING]: Consider using mount module rather than running mount
但据我所知,没有简单的选择可以做到这一点。
我错过了什么吗?
最佳答案
你是对的,当前版本的 Ansible 中的 mount
模块以每次挂载为基础工作,不允许挂载 /etc/fstab
中定义的所有文件系统.您执行任务的方式是正确的。
您在输出中看到的是警告:
[WARNING]: Consider using mount module rather than running mount
Ansible 检查您是否正在通过 command
模块运行 mount
命令,并建议使用 native 模块。
Ansible 不会执行高级语法分析来验证您在命令调用中使用的特定参数集是否可以使用 native 模块参数来实现。
通过将 warn
参数设置为 no<,您可以针对每个任务禁用
:shell
和 command
模块的警告
- name: mount all
command: mount -a
args:
warn: no
become: true
关于ansible - 如何使用 Ansible 挂载 fstab 上列出的所有分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41292850/