mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
sudoers: display stderr raised while validation (#9871)
* sudoers: display stderr raised while validation * Print stdout and stderr raised from sudoers validation Fixes: #9674 Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com> * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> --------- Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
3
changelogs/fragments/sudoers.yml
Normal file
3
changelogs/fragments/sudoers.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- sudoers - display stdout and stderr raised while failed validation (https://github.com/ansible-collections/community.general/issues/9674, https://github.com/ansible-collections/community.general/pull/9871).
|
||||||
@@ -246,7 +246,7 @@ class Sudoers(object):
|
|||||||
rc, stdout, stderr = self.module.run_command(check_command, data=self.content())
|
rc, stdout, stderr = self.module.run_command(check_command, data=self.content())
|
||||||
|
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
raise Exception('Failed to validate sudoers rule:\n{stdout}'.format(stdout=stdout))
|
self.module.fail_json(msg='Failed to validate sudoers rule:\n{stdout}'.format(stdout=stdout or stderr), stdout=stdout, stderr=stderr)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.state == 'absent':
|
if self.state == 'absent':
|
||||||
|
|||||||
@@ -284,6 +284,8 @@
|
|||||||
that:
|
that:
|
||||||
- edge_case_1 is failed
|
- edge_case_1 is failed
|
||||||
- "'Failed to validate sudoers rule' in edge_case_1.msg"
|
- "'Failed to validate sudoers rule' in edge_case_1.msg"
|
||||||
|
- edge_case_1.stdout is defined
|
||||||
|
- edge_case_1.stderr is defined
|
||||||
- edge_case_2 is not failed
|
- edge_case_2 is not failed
|
||||||
|
|
||||||
- name: Check missing validation edge case
|
- name: Check missing validation edge case
|
||||||
|
|||||||
Reference in New Issue
Block a user