Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/pamd/tasks/main.yml

raw
1 # Copyright (c) 2021, Alexei Znamensky
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 - name: Set value for temp limit configuration
6 set_fact:
7 test_pamd_file: "/tmp/pamd_file"
8
9 - name: Create temporary pam.d file
10 copy:
11 content: "session required pam_lastlog.so silent showfailed"
12 dest: "{{ test_pamd_file }}"
13 - name: Test working on a single-line file works (2925)
14 community.general.pamd:
15 path: /tmp
16 name: pamd_file
17 type: session
18 control: required
19 module_path: pam_lastlog.so
20 module_arguments: silent
21 state: args_absent
22 register: pamd_file_output
23 - name: Check if changes made
24 assert:
25 that:
26 - pamd_file_output is changed
27
28 - name: Test removing all arguments from an entry (3260)
29 community.general.pamd:
30 path: /tmp
31 name: pamd_file
32 type: session
33 control: required
34 module_path: pam_lastlog.so
35 module_arguments: ""
36 state: updated
37 register: pamd_file_output_noargs
38 - name: Read back the file (3260)
39 slurp:
40 src: "{{ test_pamd_file }}"
41 register: pamd_file_slurp_noargs
42 - name: Check if changes made (3260)
43 vars:
44 line_array: "{{ (pamd_file_slurp_noargs.content|b64decode).split('\n')[2].split() }}"
45 assert:
46 that:
47 - pamd_file_output_noargs is changed
48 - line_array == ['session', 'required', 'pam_lastlog.so']
49
50 - name: Create temporary pam.d file
51 copy:
52 content: ""
53 dest: "{{ test_pamd_file }}"
54 # This test merely demonstrates that, as-is, module will not perform any changes on an empty file
55 # All the existing values for "state" will first search for a rule matching type, control, module_path
56 # and will not perform any change whatsoever if no existing rules match.
57 - name: Test working on a empty file works (2925)
58 community.general.pamd:
59 path: /tmp
60 name: pamd_file
61 type: session
62 control: required
63 module_path: pam_lastlog.so
64 module_arguments: silent
65 register: pamd_file_output_empty
66 - name: Read back the file
67 slurp:
68 src: "{{ test_pamd_file }}"
69 register: pamd_file_slurp
70 - name: Check if changes made
71 assert:
72 that:
73 - pamd_file_output_empty is not changed
74 - pamd_file_slurp.content|b64decode == ''