fix:prepare阶段的一些小问题

pull/1086/head
gjmzj 2021-10-17 10:33:00 +08:00
parent 7b4fd5686f
commit 873876a3f0
5 changed files with 22 additions and 16 deletions

View File

@ -22,6 +22,7 @@
- socat # 用于port forwarding - socat # 用于port forwarding
state: present state: present
when: 'INSTALL_SOURCE != "offline"' when: 'INSTALL_SOURCE != "offline"'
ignore_errors: true
# 离线安装基础软件包 # 离线安装基础软件包
- import_tasks: offline.yml - import_tasks: offline.yml

View File

@ -14,15 +14,6 @@
set_fact: set_fact:
KERNEL_VER: "{{ ansible_kernel.split('-')[0].split('.')[0]|int + ansible_kernel.split('-')[0].split('.')[1]|int/100 }}" 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"
# 若提示nf_conntrack_ipv4模块不存在错误可以忽略
- name: 加载内核模块 - name: 加载内核模块
modprobe: name={{ item }} state=present modprobe: name={{ item }} state=present
with_items: with_items:
@ -32,9 +23,12 @@
- ip_vs_wrr - ip_vs_wrr
- ip_vs_sh - ip_vs_sh
- nf_conntrack - nf_conntrack
- nf_conntrack_ipv4
ignore_errors: true ignore_errors: true
- name: 尝试加载nf_conntrack_ipv4
shell: 'modprobe nf_conntrack_ipv4 || echo "NoFound"'
register: NF_CONNTRACK_IPV4
- name: 启用systemd自动加载模块服务 - name: 启用systemd自动加载模块服务
service: name=systemd-modules-load enabled=yes service: name=systemd-modules-load enabled=yes

View File

@ -1,10 +1,10 @@
# 系统基础软件环境 # 系统基础软件环境
#- name: apt更新缓存刷新 - name: apt更新缓存刷新
# apt: update_cache=yes cache_valid_time=72000 apt: update_cache=yes cache_valid_time=72000
# ignore_errors: true ignore_errors: true
# when: when:
# - 'ansible_distribution in ["Ubuntu","Debian"]' - 'ansible_distribution in ["Ubuntu","Debian"]'
# - 'INSTALL_SOURCE != "offline"' - 'INSTALL_SOURCE != "offline"'
- import_tasks: ubuntu.yml - import_tasks: ubuntu.yml
when: 'ansible_distribution in ["Ubuntu","Debian"]' when: 'ansible_distribution in ["Ubuntu","Debian"]'
@ -23,6 +23,14 @@
- /root/.kube - /root/.kube
- /opt/kube/images - /opt/kube/images
# 某些系统没有/usr/bin/python需要配置一个软链接否则connection: local的任务会失败
# 如果仍旧出现任务失败,重新执行一遍即可 https://github.com/ansible/ansible/issues/64903
- name: symlink /usr/bin/python -> /usr/bin/python3
raw: |
if [ -f /usr/bin/python3 ] && [ ! -f /usr/bin/python ]; then
ln --symbolic /usr/bin/python3 /usr/bin/python;
fi
- name: 写入环境变量$PATH - name: 写入环境变量$PATH
lineinfile: lineinfile:
dest: ~/.bashrc dest: ~/.bashrc

View File

@ -26,6 +26,7 @@
- socat # 用于port forwarding - socat # 用于port forwarding
state: present state: present
when: 'INSTALL_SOURCE != "offline"' when: 'INSTALL_SOURCE != "offline"'
ignore_errors: true
# 离线安装基础软件包 # 离线安装基础软件包
- import_tasks: offline.yml - import_tasks: offline.yml

View File

@ -4,4 +4,6 @@ ip_vs_rr
ip_vs_wrr ip_vs_wrr
ip_vs_sh ip_vs_sh
nf_conntrack nf_conntrack
{% if 'NoFound' not in NF_CONNTRACK_IPV4.stdout %}
nf_conntrack_ipv4 nf_conntrack_ipv4
{% endif %}