diff --git a/initializers/groups.yml b/initializers/groups.yml index 45f4703..15213a6 100644 --- a/initializers/groups.yml +++ b/initializers/groups.yml @@ -1,9 +1,9 @@ -# - name: applications +# applications: # users: # - technical_user -# - name: readers +# readers: # users: # - reader -# - name: writers +# writers: # users: # - writer diff --git a/initializers/users.yml b/initializers/users.yml index ccf106f..c163d50 100644 --- a/initializers/users.yml +++ b/initializers/users.yml @@ -1,10 +1,10 @@ -# - username: technical_user +# technical_user: # api_token: 0123456789technicaluser789abcdef01234567 # must be looooong! -# - username: reader +# reader: # password: reader -# - username: writer +# writer: # password: writer -# - username: jdoe +# jdoe: # first_name: John # last_name: Doe # api_token: 0123456789jdoe789abcdef01234567jdoe diff --git a/startup_scripts/010_groups.py b/startup_scripts/010_groups.py index 2abd1ba..39aca53 100644 --- a/startup_scripts/010_groups.py +++ b/startup_scripts/010_groups.py @@ -7,15 +7,13 @@ groups = load_yaml("/opt/netbox/initializers/groups.yml") if groups is None: sys.exit() -for params in groups: - groupname = params["name"] - +for groupname, group_details in groups.items(): group, created = AdminGroup.objects.get_or_create(name=groupname) if created: print("👥 Created group", groupname) - for username in params.get("users", []): + for username in group_details.get("users", []): user = AdminUser.objects.get(username=username) if user: