I wish to create entries in /etc/security.limits.conf
The data structure will look something like this:
limits:
- root:
- "soft nproc unlimited"
- "hard nfile unlimited"
- ec2-user:
- "soft nproc 4096"
Producing lines in /etc/security.conf like so:
root soft nproc unlimited
root hard nfile unlimited
ec2-user soft nproc 4096
The data definition produces a dictionary of arrays. The outer dictionary is keyed by user, each of which has its own array of lines to add.
I expect the code to look something like this pseudocode:
for user in $limits
for line in $user
lineinfile $line ...
end
end
I just can't see how to do this with Ansible.
I've been doing debugging with a debug task so I can see what the {{ item }} contains - like so:
- name: limits | Set limits in /etc/security/limits.conf
debug:
msg: item is {{ item }}
loop: "{{ limits }} "
But how do I get at the individual elements of the array? There could be up to 16 possible array elements - one for each tunable parameter.
I've found this impossible to google - all the results refer to Ansible docs, which I've read thoroughly - is not always with comprehension.
Any pointers much appreciated, and apologies if I'm missing something obvious!
blockinfiletoo, if you want "to leave alone what's there".