From bcdd1dc9518304b55fa6cdb6228df3e0a5b798ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Szcz=C4=99sny?= Date: Mon, 1 Apr 2019 16:18:33 +0200 Subject: [PATCH] pamd: fix idempotence issue when removing rules (#54105) --- changelogs/fragments/pamd-make-idempotence-fix.yaml | 2 ++ lib/ansible/modules/system/pamd.py | 2 +- test/units/modules/system/test_pamd.py | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/pamd-make-idempotence-fix.yaml diff --git a/changelogs/fragments/pamd-make-idempotence-fix.yaml b/changelogs/fragments/pamd-make-idempotence-fix.yaml new file mode 100644 index 00000000000..fbafe7306a0 --- /dev/null +++ b/changelogs/fragments/pamd-make-idempotence-fix.yaml @@ -0,0 +1,2 @@ +bugfixes: + - pamd - fix idempotence issue when removing rules diff --git a/lib/ansible/modules/system/pamd.py b/lib/ansible/modules/system/pamd.py index 0179c9562e8..d55c0126b44 100644 --- a/lib/ansible/modules/system/pamd.py +++ b/lib/ansible/modules/system/pamd.py @@ -482,7 +482,7 @@ class PamdService(object): else: self._head = current_line.next current_line.next.prev = None - changed += 1 + changed += 1 current_line = current_line.next return changed diff --git a/test/units/modules/system/test_pamd.py b/test/units/modules/system/test_pamd.py index 5d27edc729d..35d4cb1c3af 100644 --- a/test/units/modules/system/test_pamd.py +++ b/test/units/modules/system/test_pamd.py @@ -349,5 +349,7 @@ session required pam_unix.so""" def test_remove_rule(self): self.assertTrue(self.pamd.remove('account', 'required', 'pam_unix.so')) + # Second run should not change anything + self.assertFalse(self.pamd.remove('account', 'required', 'pam_unix.so')) test_rule = PamdRule('account', 'required', 'pam_unix.so') self.assertNotIn(str(test_rule), str(self.pamd))