2018-09-02 14:08:51 +08:00
|
|
|
# 禁用系统swap
|
|
|
|
- name: 禁用系统 swap
|
|
|
|
shell: "swapoff -a && sysctl -w vm.swappiness=0"
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: 删除fstab swap 相关配置
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/fstab
|
|
|
|
regexp: 'swap'
|
|
|
|
state: absent
|
|
|
|
backup: 'yes'
|
|
|
|
|
|
|
|
- name: 加载内核模块
|
|
|
|
modprobe: name={{ item }} state=present
|
|
|
|
with_items:
|
|
|
|
- br_netfilter
|
|
|
|
- ip_vs
|
|
|
|
- ip_vs_rr
|
|
|
|
- ip_vs_wrr
|
|
|
|
- ip_vs_sh
|
2019-04-09 17:39:13 +08:00
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: 转换内核版本为浮点数
|
|
|
|
set_fact:
|
|
|
|
KERNEL_VER: "{{ ansible_kernel.split('-')[0].split('.')[0]|int + ansible_kernel.split('-')[0].split('.')[1]|int/100 }}"
|
|
|
|
|
|
|
|
- name: 加载内核模块 nf_conntrack
|
|
|
|
modprobe: name=nf_conntrack state=present
|
|
|
|
when: "KERNEL_VER|float >= 4.19"
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: 加载内核模块 nf_conntrack_ipv4
|
|
|
|
modprobe: name=nf_conntrack_ipv4 state=present
|
|
|
|
when: "KERNEL_VER|float < 4.19"
|
2018-09-02 14:08:51 +08:00
|
|
|
ignore_errors: true
|
|
|
|
|
2019-01-24 11:06:48 +08:00
|
|
|
- name: 启用systemd自动加载模块服务
|
|
|
|
service: name=systemd-modules-load enabled=yes
|
|
|
|
|
|
|
|
- name: 增加内核模块开机加载配置
|
|
|
|
template: src=10-k8s-modules.conf.j2 dest=/etc/modules-load.d/10-k8s-modules.conf
|
2018-11-10 09:52:57 +08:00
|
|
|
|
2018-09-05 09:24:32 +08:00
|
|
|
# 设置系统参数for k8s
|
|
|
|
# 消除docker info 警告WARNING: bridge-nf-call-ip[6]tables is disabled
|
|
|
|
- name: 设置系统参数
|
|
|
|
template: src=95-k8s-sysctl.conf.j2 dest=/etc/sysctl.d/95-k8s-sysctl.conf
|
|
|
|
|
|
|
|
- name: 生效系统参数
|
|
|
|
shell: "sysctl -p /etc/sysctl.d/95-k8s-sysctl.conf"
|
|
|
|
ignore_errors: true
|
2019-01-24 11:06:48 +08:00
|
|
|
|
|
|
|
- name: 设置系统 ulimits
|
|
|
|
template: src=30-k8s-ulimits.conf.j2 dest=/etc/security/limits.d/30-k8s-ulimits.conf
|
2019-03-28 09:44:56 +08:00
|
|
|
|
|
|
|
- name: 把SCTP列入内核模块黑名单
|
|
|
|
copy: src=sctp.conf dest=/etc/modprobe.d/sctp.conf
|