revert startup scripts to use key for object name

This commit is contained in:
ryanmerolle 2021-04-24 10:41:06 -04:00
parent 71d8ac10ac
commit a1e0c52825
3 changed files with 9 additions and 11 deletions

View File

@ -1,9 +1,9 @@
# - name: applications
# applications:
# users:
# - technical_user
# - name: readers
# readers:
# users:
# - reader
# - name: writers
# writers:
# users:
# - writer

View File

@ -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

View File

@ -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: