From 7ee25c262d4ae3362dec6a1666fd01f3e60c66b5 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Tue, 26 Nov 2019 11:07:46 +0000 Subject: [PATCH] minor fix --- roles/prepare/tasks/common.yml | 27 +++++++++---------- .../prepare/templates/10-k8s-modules.conf.j2 | 3 +-- tools/02.addnode.yml | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/roles/prepare/tasks/common.yml b/roles/prepare/tasks/common.yml index 2c17474..2bc3d37 100644 --- a/roles/prepare/tasks/common.yml +++ b/roles/prepare/tasks/common.yml @@ -10,6 +10,18 @@ state: absent backup: 'yes' +- name: 转换内核版本为浮点数 + set_fact: + KERNEL_VER: "{{ ansible_kernel.split('-')[0].split('.')[0]|int + ansible_kernel.split('-')[0].split('.')[1]|int/100 }}" + +- name: 设置 nf_conntrack 模块名 + set_fact: NF_CONNTRACK="nf_conntrack" + when: "KERNEL_VER|float >= 4.19" + +- name: 设置 nf_conntrack_ipv4 模块名 + set_fact: NF_CONNTRACK="nf_conntrack_ipv4" + when: "KERNEL_VER|float < 4.19" + - name: 加载内核模块 modprobe: name={{ item }} state=present with_items: @@ -18,20 +30,7 @@ - ip_vs_rr - ip_vs_wrr - ip_vs_sh - 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" + - "{{ NF_CONNTRACK }}" ignore_errors: true - name: 启用systemd自动加载模块服务 diff --git a/roles/prepare/templates/10-k8s-modules.conf.j2 b/roles/prepare/templates/10-k8s-modules.conf.j2 index 5c48d30..e85f819 100644 --- a/roles/prepare/templates/10-k8s-modules.conf.j2 +++ b/roles/prepare/templates/10-k8s-modules.conf.j2 @@ -3,5 +3,4 @@ ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh -nf_conntrack_ipv4 -nf_conntrack +{{ NF_CONNTRACK }} diff --git a/tools/02.addnode.yml b/tools/02.addnode.yml index 5420f91..0c8d0cd 100644 --- a/tools/02.addnode.yml +++ b/tools/02.addnode.yml @@ -22,7 +22,7 @@ with_fileglob: - "{{ base_dir }}/down/coredns*.tar" - "{{ base_dir }}/down/dashboard*.tar" - - "{{ base_dir }}/down/heapster*.tar" + - "{{ base_dir }}/down/metrics-scraper*.tar" - "{{ base_dir }}/down/metrics*.tar" - "{{ base_dir }}/down/traefik*.tar" ignore_errors: true