netbox-docker/startup_scripts/310_secret_roles.py

16 lines
381 B
Python
Raw Normal View History

import sys
2020-12-30 01:36:58 +01:00
from secrets.models import SecretRole
2020-12-30 01:36:58 +01:00
from startup_script_utils import load_yaml
secret_roles = load_yaml("/opt/netbox/initializers/secret_roles.yml")
2020-12-30 01:36:58 +01:00
if secret_roles is None:
sys.exit()
2020-12-30 01:36:58 +01:00
for params in secret_roles:
secret_role, created = SecretRole.objects.get_or_create(**params)
2020-12-30 01:36:58 +01:00
if created:
print("🔑 Created Secret Role", secret_role.name)