|
 |
aa384d |
#!/usr/bin/python3
|
|
 |
aa384d |
|
|
Theo Chatzimichos |
e53270 |
# Checks if the declared {salt,pillar}/role/*.sls files actually match an
|
|
Theo Chatzimichos |
e53270 |
# assigned role to a minion
|
|
 |
aa384d |
|
|
 |
aa384d |
import os
|
|
 |
aa384d |
import sys
|
|
Theo Chatzimichos |
e53270 |
from get_roles import get_roles
|
|
 |
aa384d |
|
|
 |
b49512 |
status = 0
|
|
 |
aa384d |
|
|
Theo Chatzimichos |
e53270 |
roles = get_roles(with_base=True)
|
|
 |
aa384d |
|
|
 |
aa384d |
for directory in ['salt', 'pillar']:
|
|
 |
aa384d |
for sls in os.listdir('%s/role' % directory):
|
|
 |
aa384d |
if sls.endswith('.sls'):
|
|
 |
5c774c |
with open('%s/role/%s' % (directory, sls)) as f:
|
|
Theo Chatzimichos |
e53270 |
if sls.split('.sls')[0] not in roles:
|
|
 |
aa384d |
print ('%s/role/%s not in roles' % (directory, sls))
|
|
 |
aa384d |
status = 1
|
|
 |
aa384d |
|
|
 |
aa384d |
sys.exit(status)
|