Created
July 9, 2016 03:32
-
-
Save bryder/7b35447c4efe77e1a9c70c06bd546640 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
- vars: | |
ansible_added_line: "# Line added by ansible " | |
nofile_limits: | |
- user: root | |
limits: | |
- soft: 65001 | |
- hard: 70001 | |
- user: some_user | |
limits: | |
- soft: 65001 | |
- hard: 65001 | |
- tasks: | |
- name: remove old limits | |
lineinfile: | |
dest: /etc/security/limits.conf | |
regexp: "^{{ item.0.user }}\\s+{{ item.1.keys()[0] }}\\s+nofile\\s+(?!{{ item.1[item.1.keys()[0]] }} {{ ansible_added_line}})" | |
state: absent | |
with_subelements: | |
- "{{ nofile_limits }}" | |
- limits | |
- name: add limits | |
lineinfile: | |
dest: /etc/security/limits.conf | |
state: present | |
line: "{{ item.0.user }} {{ item.1.keys()[0] }} nofile {{ item.1[item.1.keys()[0]] }} {{ ansible_added_line}}" | |
with_subelements: | |
- "{{ nofile_limits }}" | |
- limits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment