summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Pfuetzenreuter2023-01-21 19:40:19 +0100
committerGeorg Pfuetzenreuter2023-01-21 19:40:19 +0100
commit50c638a00024141cea7dfc445fa17bf336d5db83 (patch)
tree92b3e8e59ee7cb29b0d782c10ed4e8e2a018061b
parentab2f6802a919030445c1a7dac0c1335f528805e9 (diff)
downloadsalt-50c638a00024141cea7dfc445fa17bf336d5db83.tar.gz
salt-50c638a00024141cea7dfc445fa17bf336d5db83.tar.bz2
salt-50c638a00024141cea7dfc445fa17bf336d5db83.zip
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 <mail@georg-pfuetzenreuter.net>
-rwxr-xr-xbin/roles.py13
1 files changed, 10 insertions, 3 deletions
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__':