salt/bin/roles.py
Georg Pfuetzenreuter 442ff683d1
roles.py: support nested roles + cli invocation
- walk both pillar and salt roles
- support nested roles / state files in subdirectories
- allow test invocation of the script from the command line

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2023-01-21 14:52:48 +01:00

19 lines
451 B
Python
Executable File

#!/usr/bin/env python3
import os
roles = []
excluded = ['common-suse', 'minion']
def get():
for root in ['pillar', 'salt']:
for rootdir, subdirs, files in os.walk(os.path.join(root, 'role')):
for file in files:
role = os.path.splitext(file)[0]
if not role in excluded and not role in roles:
roles.append(role)
return roles
if __name__ == '__main__':
print(get())