如何解决将挂载存储在变量中并注释或禁用交换挂载
新手提醒!!
这个想法是在 fstab 中列出包含单词 swap 的挂载并将它们存储在一个变量中,然后禁用或注释它。 我可以使用正则表达式轻松禁用它:
- name: Force quit swap
command: swapoff {{ swap.stdout }}
- name: Disabling swap
shell: "swapoff --all"
become: true
- name: Disable swap permanently,persist reboots
replace:
path: /etc/fstab
regexp: '^([^#].*?\sswap\s+sw\s+.*)$'
replace: '# \1'
backup: yes
但我被要求改用 ansible_mount。 你能帮忙吗?
解决方法
请查看 mount 文档并使用状态 absent
。
- name: Unmount swap
mount:
name: swap
fstype: swap
state: absent
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。