- block:
  - name: Set the max opened files at the system level
    sysctl:
      name: fs.file-max
      value: "{{ system_max_open_files_limit }}"
      state: present
      reload: no

  - name: Set the max opened files for every user
    pam_limits:
      domain: "*"
      limit_item: nofile
      value: "{{ item.value }}"
      limit_type: "{{ item.type }}"
    with_items:
      - { type: "hard", value: "{{ user_max_open_files_limit }}" }
      - { type: "soft", value: "{{ user_max_open_files_limit }}" }
  become: yes
