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>
pull/1587/head
Abhijeet Kasurde 2021-01-03 18:02:54 +05:30 committed by GitHub
parent 491b622041
commit 785951484b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 98 additions and 1 deletions

View File

@ -134,8 +134,8 @@ EXAMPLES = r'''
'''
import os
import tempfile
import re
import tempfile
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native

View File

@ -0,0 +1,5 @@
shippable/posix/group1
skip/aix
skip/freebsd
skip/osx
skip/macos

View File

@ -0,0 +1 @@
# /etc/security/limits.conf

View 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