revert startup scripts to use key for object name
This commit is contained in:
parent
71d8ac10ac
commit
a1e0c52825
|
@ -1,9 +1,9 @@
|
||||||
# - name: applications
|
# applications:
|
||||||
# users:
|
# users:
|
||||||
# - technical_user
|
# - technical_user
|
||||||
# - name: readers
|
# readers:
|
||||||
# users:
|
# users:
|
||||||
# - reader
|
# - reader
|
||||||
# - name: writers
|
# writers:
|
||||||
# users:
|
# users:
|
||||||
# - writer
|
# - writer
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
# - username: technical_user
|
# technical_user:
|
||||||
# api_token: 0123456789technicaluser789abcdef01234567 # must be looooong!
|
# api_token: 0123456789technicaluser789abcdef01234567 # must be looooong!
|
||||||
# - username: reader
|
# reader:
|
||||||
# password: reader
|
# password: reader
|
||||||
# - username: writer
|
# writer:
|
||||||
# password: writer
|
# password: writer
|
||||||
# - username: jdoe
|
# jdoe:
|
||||||
# first_name: John
|
# first_name: John
|
||||||
# last_name: Doe
|
# last_name: Doe
|
||||||
# api_token: 0123456789jdoe789abcdef01234567jdoe
|
# api_token: 0123456789jdoe789abcdef01234567jdoe
|
||||||
|
|
|
@ -7,15 +7,13 @@ groups = load_yaml("/opt/netbox/initializers/groups.yml")
|
||||||
if groups is None:
|
if groups is None:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
for params in groups:
|
for groupname, group_details in groups.items():
|
||||||
groupname = params["name"]
|
|
||||||
|
|
||||||
group, created = AdminGroup.objects.get_or_create(name=groupname)
|
group, created = AdminGroup.objects.get_or_create(name=groupname)
|
||||||
|
|
||||||
if created:
|
if created:
|
||||||
print("👥 Created group", groupname)
|
print("👥 Created group", groupname)
|
||||||
|
|
||||||
for username in params.get("users", []):
|
for username in group_details.get("users", []):
|
||||||
user = AdminUser.objects.get(username=username)
|
user = AdminUser.objects.get(username=username)
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
|
|
Loading…
Reference in New Issue