483b06
From 9cacddeb763c3e07ee31ac5bc2528cfb274b57b1 Mon Sep 17 00:00:00 2001
483b06
From: David Kupka <dkupka@redhat.com>
483b06
Date: Mon, 27 Mar 2017 09:30:53 +0200
483b06
Subject: [PATCH] httpinstance.disable_system_trust: Don't fail if module 'Root
483b06
 Certs' is not available
483b06
483b06
Server installation failed when attmpting to disable module 'Root Certs' and
483b06
the module was not available in HTTP_ALIAS_DIR. When the module is not
483b06
available there's no need to disable it and the error may be treated as
483b06
success.
483b06
483b06
https://pagure.io/freeipa/issue/6803
483b06
483b06
Reviewed-By: Christian Heimes <cheimes@redhat.com>
483b06
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
483b06
---
483b06
 ipaserver/install/httpinstance.py | 14 +++++++++++---
483b06
 1 file changed, 11 insertions(+), 3 deletions(-)
483b06
483b06
diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
483b06
index f6f0b0c4f6acd648aa9f6f5d7400617613245473..01b55e7a7b00d020b7745c419267ad4f0ba86804 100644
483b06
--- a/ipaserver/install/httpinstance.py
483b06
+++ b/ipaserver/install/httpinstance.py
483b06
@@ -355,9 +355,17 @@ class HTTPInstance(service.Service):
483b06
         name = 'Root Certs'
483b06
         args = [paths.MODUTIL, '-dbdir', paths.HTTPD_ALIAS_DIR, '-force']
483b06
 
483b06
-        result = ipautil.run(args + ['-list', name],
483b06
-                             env={},
483b06
-                             capture_output=True)
483b06
+        try:
483b06
+            result = ipautil.run(args + ['-list', name],
483b06
+                                 env={},
483b06
+                                 capture_output=True)
483b06
+        except ipautil.CalledProcessError as e:
483b06
+            if e.returncode == 29:  # ERROR: Module not found in database.
483b06
+                root_logger.debug(
483b06
+                    'Module %s not available, treating as disabled', name)
483b06
+                return False
483b06
+            raise
483b06
+
483b06
         if 'Status: Enabled' in result.output:
483b06
             ipautil.run(args + ['-disable', name], env={})
483b06
             return True
483b06
-- 
483b06
2.12.1
483b06