From 50c638a00024141cea7dfc445fa17bf336d5db83 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Sat, 21 Jan 2023 19:40:19 +0100 Subject: roles.py: repair role walking Improve nested role support introduced with 442ff683d1e5b3c15a7ef90b27c4be2b3e70ff30 by correctly converting subdirectories into nested state references. Signed-off-by: Georg Pfuetzenreuter --- bin/roles.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'bin/roles.py') diff --git a/bin/roles.py b/bin/roles.py index 32de0cf..e4a0587 100755 --- a/bin/roles.py +++ b/bin/roles.py @@ -8,10 +8,17 @@ excluded = ['common-suse', 'minion'] def get(): for root in ['pillar', 'salt']: for rootdir, subdirs, files in os.walk(os.path.join(root, 'role')): + myrootdir = rootdir.split('/') + if len(myrootdir) > 2: + level = myrootdir[2:] for file in files: - role = os.path.splitext(file)[0] - if not role in excluded and not role in roles: - roles.append(role) + splitfile = os.path.splitext(file) + if len(splitfile) == 2 and splitfile[1] == '.sls': + role = os.path.splitext(file)[0] + if len(myrootdir) > 2: + role = '.'.join(level) + '.' + role + if not role in excluded and not role in roles: + roles.append(role) return roles if __name__ == '__main__': -- cgit v1.2.3