From c591d6fe4bfedb89d59a06f6a05f557201339e26 Mon Sep 17 00:00:00 2001 From: John Van de Meulebrouck Brendgard Date: Tue, 12 Feb 2019 16:20:54 +0100 Subject: [PATCH 1/2] Changed from re.search to re.match in db.py because re.search would match on broken regex, nodes that have a part of the name in common with other nodes etc. --- fabfile/db.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fabfile/db.py b/fabfile/db.py index 129aa50..67b6645 100644 --- a/fabfile/db.py +++ b/fabfile/db.py @@ -17,7 +17,7 @@ def _load_db(): members = dict() for node_name in all_hosts: for reg,cls in rules.iteritems(): - if re.search(reg,node_name): + if re.match(reg,node_name): for cls_name in cls.keys(): h = members.get(cls_name,[]) h.append(node_name) @@ -28,10 +28,14 @@ def _load_db(): for node_name in all_hosts: node_classes = dict() for reg,cls in rules.iteritems(): - if re.search(reg,node_name): + if re.match(reg,node_name): node_classes.update(cls) classes[node_name] = node_classes + # Sort member lists for a more easy to read diff + for cls in members.keys(): + members[cls].sort() + return dict(classes=classes,members=members) _db = None From fba9ddb8f7168d6042505322271de4c7368e8fe5 Mon Sep 17 00:00:00 2001 From: John Van de Meulebrouck Brendgard Date: Tue, 12 Feb 2019 16:21:24 +0100 Subject: [PATCH 2/2] Changed example regex to make it a bit more apparent that the regex is to be used with re.match and not re.search --- global/overlay/etc/puppet/cosmos-rules.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/global/overlay/etc/puppet/cosmos-rules.yaml b/global/overlay/etc/puppet/cosmos-rules.yaml index d9dc495..cffd808 100644 --- a/global/overlay/etc/puppet/cosmos-rules.yaml +++ b/global/overlay/etc/puppet/cosmos-rules.yaml @@ -1,2 +1,3 @@ -'ns[0-9]?.mnt.se$': +# Note that the matching is done with re.match() +'^ns[0-9]?.mnt.se$': nameserver: