From c09656b0c539403edf6b888c26a8f8f1dc163a4b Mon Sep 17 00:00:00 2001 From: WeiLai Date: Sun, 16 Apr 2023 12:44:07 +0800 Subject: [PATCH] Update common.yml --- roles/prepare/tasks/common.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/roles/prepare/tasks/common.yml b/roles/prepare/tasks/common.yml index eb1d141..b2c8f5c 100644 --- a/roles/prepare/tasks/common.yml +++ b/roles/prepare/tasks/common.yml @@ -41,6 +41,25 @@ - name: 设置系统参数 template: src=95-k8s-sysctl.conf.j2 dest=/etc/sysctl.d/95-k8s-sysctl.conf +- name: 查看是否需要设置 fs.may_detach_mounts + stat: + path: /proc/sys/fs/may_detach_mounts + get_attributes: no + get_checksum: no + get_mime: no + register: fs_may_detach_mounts + ignore_errors: true + +- name: 当需要时,设置 fs.may_detach_mounts 为 1 + sysctl: + sysctl_file: "/etc/sysctl.d/95-k8s-sysctl.conf" + name: fs.may_detach_mounts + value: 1 + state: present + reload: yes + when: fs_may_detach_mounts.stat.exists|bool + + - name: 生效系统参数 shell: "source /etc/profile; sysctl -p /etc/sysctl.d/95-k8s-sysctl.conf" ignore_errors: true