|
2 | 2 | - hosts: all |
3 | 3 | gather_facts: no |
4 | 4 | become: yes |
| 5 | + vars: |
| 6 | + nofile_soft: 65535 |
| 7 | + nofile_hard: 65535 |
| 8 | + file_max: 2097152 |
5 | 9 | # Install longhorn dependencies |
6 | 10 | tasks: |
7 | 11 | - name: install open-iscsi |
|
34 | 38 | # some cloud providers may not use the multipathd service |
35 | 39 | # thus make the error not fatal. |
36 | 40 | ignore_errors: yes |
| 41 | + |
| 42 | + # Update node limits. |
| 43 | + - name: Modify limits.conf |
| 44 | + blockinfile: |
| 45 | + path: /etc/security/limits.conf |
| 46 | + block: | |
| 47 | + * soft nofile {{ nofile_soft }} |
| 48 | + * hard nofile {{ nofile_hard }} |
| 49 | + root soft nofile {{ nofile_soft }} |
| 50 | + root hard nofile {{ nofile_hard }} |
| 51 | + state: present |
| 52 | + |
| 53 | + - name: Ensure PAM limits are enabled |
| 54 | + lineinfile: |
| 55 | + path: /etc/pam.d/common-session |
| 56 | + line: "session required pam_limits.so" |
| 57 | + state: present |
| 58 | + |
| 59 | + - name: Ensure PAM limits are enabled for non-interactive sessions |
| 60 | + lineinfile: |
| 61 | + path: /etc/pam.d/common-session-noninteractive |
| 62 | + line: "session required pam_limits.so" |
| 63 | + state: present |
| 64 | + |
| 65 | + - name: Configure systemd system limits |
| 66 | + ansible.builtin.lineinfile: |
| 67 | + path: /etc/systemd/system.conf |
| 68 | + regexp: "^#?DefaultLimitNOFILE=" |
| 69 | + line: "DefaultLimitNOFILE={{ nofile_hard }}" |
| 70 | + |
| 71 | + - name: Configure systemd user limits |
| 72 | + ansible.builtin.lineinfile: |
| 73 | + path: /etc/systemd/user.conf |
| 74 | + regexp: "^#?DefaultLimitNOFILE=" |
| 75 | + line: "DefaultLimitNOFILE={{ nofile_hard }}" |
| 76 | + |
| 77 | + - name: Reload systemd configuration |
| 78 | + ansible.builtin.systemd: |
| 79 | + daemon_reload: yes |
| 80 | + |
| 81 | + - name: Set kernel file handle maximum |
| 82 | + ansible.builtin.sysctl: |
| 83 | + name: fs.file-max |
| 84 | + value: "{{ file_max }}" |
| 85 | + state: present |
| 86 | + reload: yes |
0 commit comments