diff --git a/changelogs/fragments/11072-opendj-checkrc.yml b/changelogs/fragments/11072-opendj-checkrc.yml new file mode 100644 index 0000000000..f6e6d34d1e --- /dev/null +++ b/changelogs/fragments/11072-opendj-checkrc.yml @@ -0,0 +1,2 @@ +minor_changes: + - opendj_backendprop - use Ansible construct to perform check for external commands (https://github.com/ansible-collections/community.general/pull/11072). diff --git a/plugins/modules/opendj_backendprop.py b/plugins/modules/opendj_backendprop.py index 52df42a301..e46fb4f123 100644 --- a/plugins/modules/opendj_backendprop.py +++ b/plugins/modules/opendj_backendprop.py @@ -112,11 +112,8 @@ class BackendProp: "-X", "-s", ] + password_method - rc, stdout, stderr = self._module.run_command(my_command) - if rc == 0: - return stdout - else: - self._module.fail_json(msg=f"Error message: {stderr}") + rc, stdout, stderr = self._module.run_command(my_command, check_rc=True) + return stdout def set_property(self, opendj_bindir, hostname, port, username, password_method, backend_name, name, value): my_command = [ @@ -135,11 +132,8 @@ class BackendProp: "-n", "-X", ] + password_method - rc, stdout, stderr = self._module.run_command(my_command) - if rc == 0: - return True - else: - self._module.fail_json(msg=f"Error message: {stderr}") + self._module.run_command(my_command, check_rc=True) + return True def validate_data(self, data=None, name=None, value=None): for config_line in data.split("\n"):