From 8939dddff46037aaa5c2d0fc3a52a065a2f3c44b Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Wed, 20 Jan 2021 21:02:17 -0500 Subject: [PATCH] library: fix idempotency in ceph_mgr_module The ceph mgr command output is printed on stderr instead of stdout which prevent to set the changed flag to false if the module is already enabled. Signed-off-by: Dimitri Savineau --- library/ceph_mgr_module.py | 2 +- tests/library/test_ceph_mgr_module.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/ceph_mgr_module.py b/library/ceph_mgr_module.py index e82ae6e22..54095a0c3 100644 --- a/library/ceph_mgr_module.py +++ b/library/ceph_mgr_module.py @@ -107,7 +107,7 @@ def main(): ) else: rc, out, err = module.run_command(cmd) - if out == "module '{}' is already enabled".format(name): + if 'is already enabled' in err: changed = False else: changed = True diff --git a/tests/library/test_ceph_mgr_module.py b/tests/library/test_ceph_mgr_module.py index f577c20e9..efd87bf08 100644 --- a/tests/library/test_ceph_mgr_module.py +++ b/tests/library/test_ceph_mgr_module.py @@ -93,8 +93,8 @@ class TestCephMgrModuleModule(object): 'name': fake_module, }) m_exit_json.side_effect = ca_test_common.exit_json - stdout = 'module \'{}\' is already enabled'.format(fake_module) - stderr = '' + stderr = 'module \'{}\' is already enabled'.format(fake_module) + stdout = '' rc = 0 m_run_command.return_value = rc, stdout, stderr