mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-08 19:50:30 -07:00
pam_limits: adds check mode and diff mode (#1575)
* Add integration tests fixes #827 fixes #828 Signed-off-by: Christian Krause <christian.krause@idiv.de> Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Christian Krause <christian.krause@idiv.de>
This commit is contained in:
parent
491b622041
commit
785951484b
4 changed files with 98 additions and 1 deletions
|
@ -134,8 +134,8 @@ EXAMPLES = r'''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
|
||||||
import re
|
import re
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
|
|
5
tests/integration/targets/pam_limits/aliases
Normal file
5
tests/integration/targets/pam_limits/aliases
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
shippable/posix/group1
|
||||||
|
skip/aix
|
||||||
|
skip/freebsd
|
||||||
|
skip/osx
|
||||||
|
skip/macos
|
|
@ -0,0 +1 @@
|
||||||
|
# /etc/security/limits.conf
|
91
tests/integration/targets/pam_limits/tasks/main.yml
Normal file
91
tests/integration/targets/pam_limits/tasks/main.yml
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
# Test code for the pam_limits module
|
||||||
|
# Copyright: (c) 2021, Abhijeet Kasurde <akasurde@redhat.com>
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
- name: Set value for temp limit configuration
|
||||||
|
set_fact:
|
||||||
|
test_limit_file: "/tmp/limits.conf"
|
||||||
|
|
||||||
|
- name: Copy temporary limits.conf
|
||||||
|
copy:
|
||||||
|
src: test_pam_limits.conf
|
||||||
|
dest: "{{ test_limit_file }}"
|
||||||
|
|
||||||
|
- name: Test check mode support in pam_limits
|
||||||
|
community.general.pam_limits:
|
||||||
|
domain: smith
|
||||||
|
limit_type: soft
|
||||||
|
limit_item: nofile
|
||||||
|
value: '64000'
|
||||||
|
dest: "{{ test_limit_file }}"
|
||||||
|
check_mode: yes
|
||||||
|
register: check_mode_test
|
||||||
|
|
||||||
|
- name: Test that check mode is working
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- check_mode_test is changed
|
||||||
|
|
||||||
|
- name: Add soft limit for smith user
|
||||||
|
community.general.pam_limits:
|
||||||
|
domain: smith
|
||||||
|
limit_type: soft
|
||||||
|
limit_item: nofile
|
||||||
|
value: '64000'
|
||||||
|
dest: "{{ test_limit_file }}"
|
||||||
|
register: soft_limit_test
|
||||||
|
|
||||||
|
- name: Check if changes are made
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- soft_limit_test is changed
|
||||||
|
|
||||||
|
- name: Aagin change soft limit for smith user for idempotency
|
||||||
|
community.general.pam_limits:
|
||||||
|
domain: smith
|
||||||
|
limit_type: soft
|
||||||
|
limit_item: nofile
|
||||||
|
value: '64000'
|
||||||
|
dest: "{{ test_limit_file }}"
|
||||||
|
register: soft_limit_test
|
||||||
|
|
||||||
|
- name: Check if changes are not made idempotency
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- not soft_limit_test.changed
|
||||||
|
|
||||||
|
- name: Change hard limit for Joe user for diff
|
||||||
|
community.general.pam_limits:
|
||||||
|
domain: joe
|
||||||
|
limit_type: hard
|
||||||
|
limit_item: nofile
|
||||||
|
value: '100000'
|
||||||
|
dest: "{{ test_limit_file }}"
|
||||||
|
register: hard_limit_test
|
||||||
|
diff: true
|
||||||
|
|
||||||
|
- name: Debugging output for hard limit test
|
||||||
|
debug:
|
||||||
|
msg: "{{ hard_limit_test }}"
|
||||||
|
|
||||||
|
- name: Check if changes made
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- hard_limit_test is changed
|
||||||
|
- hard_limit_test.diff.after is defined
|
||||||
|
- hard_limit_test.diff.before is defined
|
||||||
|
|
||||||
|
- name: Add comment with change
|
||||||
|
community.general.pam_limits:
|
||||||
|
domain: doom
|
||||||
|
limit_type: hard
|
||||||
|
limit_item: nofile
|
||||||
|
value: '100000'
|
||||||
|
dest: "{{ test_limit_file }}"
|
||||||
|
comment: "This is a nice comment"
|
||||||
|
register: comment_test
|
||||||
|
|
||||||
|
- name: Check if changes made
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- comment_test is changed
|
Loading…
Add table
Reference in a new issue