AC-752 Update settings to support enabling celeryd using rabbitmq on upgrade, also support config files in /etc/awx/conf.d/.

This commit is contained in:
Chris Church
2014-01-02 11:19:07 -05:00
parent a4098a6df7
commit fc6ec26ebe
5 changed files with 117 additions and 20 deletions

View File

@@ -2,21 +2,25 @@
# All Rights Reserved.
# Development settings for AWX project.
# Python
import sys
import traceback
# Django Split Settings
from split_settings.tools import optional, include
# Load default settings.
from defaults import *
# If a local_settings.py file is present in awx/settings/, use it to override
# If any local_*.py files are present in awx/settings/, use them to override
# default settings for development. If not present, we can still run using
# only the defaults.
try:
local_settings_file = os.path.join(os.path.dirname(__file__),
'local_settings.py')
execfile(local_settings_file)
# Hack so that the autoreload will detect changes to local_settings.py.
class dummymodule(str):
__file__ = property(lambda self: self)
sys.modules['local_settings'] = dummymodule(local_settings_file)
except IOError, e:
from django.core.exceptions import ImproperlyConfigured
if os.path.exists(local_settings_file):
msg = 'Unable to load %s: %s' % (local_settings_file, str(e))
raise ImproperlyConfigured(msg)
include(
optional('local_*.py'),
scope=locals(),
)
except ImportError:
traceback.print_exc()
sys.exit(1)

View File

@@ -2,6 +2,15 @@
# All Rights Reserved.
# Production settings for AWX project.
# Python
import sys
import traceback
# Django Split Settings
from split_settings.tools import optional, include
# Load default settings.
from defaults import *
DEBUG = False
@@ -30,19 +39,34 @@ INTERNAL_API_URL = 'http://127.0.0.1:80'
# This directory should not be web-accessible
JOBOUTPUT_ROOT = '/var/lib/awx/job_status/'
# Load settings from any .py files in the global conf.d directory specified in
# the environment, defaulting to /etc/awx/conf.d/.
settings_dir = os.environ.get('AWX_SETTINGS_DIR', '/etc/awx/conf.d/')
settings_files = os.path.join(settings_dir, '*.py')
# Load remaining settings from the global settings file specified in the
# environment, defaulting to /etc/awx/settings.py.
settings_file = os.environ.get('AWX_SETTINGS_FILE',
'/etc/awx/settings.py')
# Attempt to load settings from /etc/awx/settings.py first, followed by
# /etc/awx/conf.d/*.py.
try:
execfile(settings_file)
except IOError, e:
include(
settings_file,
optional(settings_files),
scope=locals(),
)
except ImportError:
traceback.print_exc()
sys.exit(1)
except IOError:
from django.core.exceptions import ImproperlyConfigured
if not os.path.exists(settings_file):
msg = 'No AWX configuration found at %s.' % settings_file
included_file = locals().get('__included_file__', '')
if (not included_file or included_file == settings_file) and not os.path.exists(settings_file):
if 'AWX_SETTINGS_FILE' not in os.environ:
msg = 'No AWX configuration found at %s.' % settings_file
msg += '\nDefine the AWX_SETTINGS_FILE environment variable to '
msg += 'specify an alternate path.'
else:
msg = 'Unable to load %s: %s' % (settings_file, str(e))
raise ImproperlyConfigured(msg)
raise ImproperlyConfigured(msg)
raise