From a0e644823e8d6582cdfebec1e6759ae3a7b758bc Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Thu, 24 Oct 2019 17:08:08 +0200
Subject: [PATCH] Cover roles with --check option

---
 src/hostinfo.py      | 1 +
 src/hostinfo/role.py | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/src/hostinfo.py b/src/hostinfo.py
index 10c84f4..33c0895 100755
--- a/src/hostinfo.py
+++ b/src/hostinfo.py
@@ -275,6 +275,7 @@ if __name__ == '__main__':
         hostinfo.dhcpd.generate(tree, options)
         hostinfo.dhcpd_ipv6.generate(tree, options)
         hostinfo.automount.generate(tree, None)
+        hostinfo.role.generate(tree, None, None)
         sys.exit(0)
 
     if options.dfs:
diff --git a/src/hostinfo/role.py b/src/hostinfo/role.py
index 61bb5d7..f8accda 100755
--- a/src/hostinfo/role.py
+++ b/src/hostinfo/role.py
@@ -2,6 +2,9 @@ import hostinfo.util as util
 
 def generate(tree, host, roles):
     by_role = get_all(tree)
+    if host == None and roles == None:
+        # Just doing sanity check of hostinfo.xml file
+        return None
     for r in roles:
         if not r in by_role:
             raise Exception("Role '%s' not found in %s" %
-- 
GitLab