diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 9471899b37..aaab3a3571 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -1,6 +1,7 @@ # Copyright (c) 2015 Ansible, Inc. # All Rights Reserved. +import base64 import os import re # noqa import sys @@ -148,7 +149,10 @@ SCHEDULE_MAX_JOBS = 10 SITE_ID = 1 # Make this unique, and don't share it with anybody. -SECRET_KEY = open('/etc/tower/SECRET_KEY', 'rb').read().strip() +if os.path.exists('/etc/tower/SECRET_KEY'): + SECRET_KEY = open('/etc/tower/SECRET_KEY', 'rb').read().strip() +else: + SECRET_KEY = base64.encodebytes(os.urandom(32)).decode().rstrip() # Hosts/domain names that are valid for this site; required if DEBUG is False # See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts