-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1171 from KubeKyrie/fix-enable-sysctl-tuning
Add playbook to enable nf_conntrack
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2023 Authors of kubean-io | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
--- | ||
- name: Enable nf_conntrack kernel module | ||
hosts: all | ||
become: true | ||
any_errors_fatal: "{{ any_errors_fatal | default(true) }}" | ||
tasks: | ||
- name: Check OS and enable nf_conntrack | ||
command: lsmod | grep nf_conntrack | ||
register: nf_conntrack_check | ||
ignore_errors: true | ||
|
||
- name: Enable nf_conntrack for non-RedHat8/Rocky OS | ||
command: modprobe nf_conntrack | ||
when: | ||
- ansible_distribution != "Rocky" or (ansible_distribution == "RedHat" and ansible_distribution_major_version != "8") | ||
- nf_conntrack_check.rc != 0 | ||
|
||
- name: Persist nf_conntrack configuration | ||
when: | ||
- ansible_distribution != "Rocky" or (ansible_distribution == "RedHat" and ansible_distribution_major_version != "8") | ||
- nf_conntrack_check.rc != 0 | ||
block: | ||
- name: Ensure nf_conntrack configuration file exists | ||
file: | ||
path: /etc/modules-load.d/nf_conntrack.conf | ||
state: touch | ||
mode: "0644" | ||
- name: Add nf_conntrack to configuration file | ||
lineinfile: | ||
path: /etc/modules-load.d/nf_conntrack.conf | ||
line: "nf_conntrack" | ||
state: present |