DebugFactor.com | Forum

Assign Multiple values in /etc/security/limits.conf for server tuning using ansible

I want to assign multiple values in /etc/security/limits.conf.
I am able to achieve it using pam_limits in four different tasks. Could you please let me know how to achieve in a single task?

tasks:
- name: Assign values
  pam_limits:
   domain: thedomainname
   limit_type: "soft"
   limit_item: "nproc"
   value: "3000"

You can use loop to achieve it in a single task.

tasks:
- name: Assign values
  pam_limits:
   domain: thedomainname
   limit_type: "{{item.type}}"
   limit_item: "{{item.key}}"
   value: "{{item.value}}"
  loop: "{{pam_values}}"

vars:
pam_values:
 - {"type":soft, "key":nproc, "value": "{{nproc_value}}"}
 - {"type":hard, "key":nproc, "value": 3000}
 - {"type":soft, "key":memlock, "value": 3000}
nproc_value: 8000