bundles/icinga2: generate icinga_users from users.json
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit
This commit is contained in:
parent
c77856f97a
commit
12cf03e03f
4 changed files with 38 additions and 7 deletions
|
@ -1,3 +1,6 @@
|
|||
from json import loads
|
||||
from os.path import join
|
||||
|
||||
defaults = {
|
||||
'apt': {
|
||||
'repos': {
|
||||
|
@ -46,3 +49,27 @@ defaults = {
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
@metadata_reactor
|
||||
def add_users_from_json(metadata):
|
||||
with open(join(repo.path, 'users.json'), 'r') as f:
|
||||
json = loads(f.read())
|
||||
|
||||
users = {}
|
||||
for uname, config in json.items():
|
||||
users[uname] = {
|
||||
'email': '',
|
||||
'phone': '',
|
||||
'is_admin': config.get('is_admin', False),
|
||||
}
|
||||
|
||||
if 'email' in config:
|
||||
users[uname]['email'] = repo.vault.decrypt(config['email'])
|
||||
if 'phone' in config:
|
||||
users[uname]['phone'] = repo.vault.decrypt(config['phone'])
|
||||
|
||||
return {
|
||||
'icinga2': {
|
||||
'icinga_users': users,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue