Skip to content

Commit

Permalink
Add root-key generation command
Browse files Browse the repository at this point in the history
  • Loading branch information
camillescottatwork committed Sep 16, 2024
1 parent 55d917a commit 2250979
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions cheeto/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def main():
database.site_write_to_puppet(site_commands)
database.site_sync_to_ldap(site_commands)
database.site_write_to_sympa(site_commands)
database.site_write_root_key(site_commands)

user_parser = database_commands.add_parser('user')
user_parser.set_defaults(func = lambda _: user_parser.print_help())
Expand Down
17 changes: 17 additions & 0 deletions cheeto/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,23 @@ def site_write_to_sympa(args: argparse.Namespace):
print(user.email, file=fp)


@subcommand('root-key',
add_site_args_req,
lambda parser: parser.add_argument('output_txt', type=Path))
def site_write_root_key(args: argparse.Namespace):
connect_to_database(args.config.mongo)

with args.output_txt.open('w') as fp:
for user in SiteUser.objects(sitename=args.site,
parent__in=GlobalUser.objects(type='admin')):
if 'root-ssh' in user.access:
if user.ssh_key:
print(f'# {user.username} <{user.email}>', file=fp)
for key in user.ssh_key:
print(key, file=fp)



#########################################
#
# load commands: cheeto database load ...
Expand Down

0 comments on commit 2250979

Please sign in to comment.