diff --git a/app_setup/setup.yml b/app_setup/setup.yml index 8e44d74347..aa00b74dda 100644 --- a/app_setup/setup.yml +++ b/app_setup/setup.yml @@ -13,8 +13,8 @@ tasks: - - name: remove python-dateutils package if installed - yum: name=python-dateutils15 state=removed + - name: remove python-dateutil package if installed + yum: name=python-dateutil15 state=removed - name: install packages from yum yum: name=$item state=installed diff --git a/app_setup/templates/local_settings.py.j2 b/app_setup/templates/local_settings.py.j2 index 42c94a3398..dfb17cdbb2 100644 --- a/app_setup/templates/local_settings.py.j2 +++ b/app_setup/templates/local_settings.py.j2 @@ -17,7 +17,7 @@ # along with Ansible Commander. If not, see . -from defaults import * +from development import * ADMINS = ( # ('Your Name', 'your_email@domain.com'), diff --git a/lib/__init__.py b/lib/__init__.py index d591e30ac7..0ffb798a33 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -1,19 +1,5 @@ # Copyright (c) 2013 AnsibleWorks, Inc. -# -# This file is part of Ansible Commander. -# -# Ansible Commander is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3 of the License. -# -# Ansible Commander is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible Commander. If not, see . - +# All Rights Reserved. __version__ = '1.2-b1' @@ -23,9 +9,11 @@ import sys __all__ = ['__version__'] def manage(): - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lib.settings') + # Default to production mode unless being called from manage.py, which sets + # the environment variable for development mode instead. + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lib.settings.production') from django.core.management import execute_from_command_line if len(sys.argv) >= 2 and sys.argv[1] in ('version', '--version'): - sys.stdout.write('acom-%s\n' % __version__) + sys.stdout.write('ansibleworks-%s\n' % __version__) else: execute_from_command_line(sys.argv) diff --git a/lib/main/management/commands/__init__.py b/lib/main/management/commands/__init__.py index 594eae475f..733687ee4b 100644 --- a/lib/main/management/commands/__init__.py +++ b/lib/main/management/commands/__init__.py @@ -31,9 +31,8 @@ def run_command_as_script(command_name): ''' # The DJANGO_SETTINGS_MODULE environment variable should already be set if - # the script is called from a celery task. - settings_module_name = os.environ.setdefault('DJANGO_SETTINGS_MODULE', - 'lib.settings') + # the script is called from a celery task. Don't attemtp to set a default. + settings_module_name = os.environ['DJANGO_SETTINGS_MODULE'] # This sys.path hack is needed when a celery task calls ansible-playbook # and needs to execute the script directly. FIXME: Figure out if this will # work when installed in a production environment. diff --git a/lib/settings/__init__.py b/lib/settings/__init__.py index 7c2eb1b420..e69de29bb2 100644 --- a/lib/settings/__init__.py +++ b/lib/settings/__init__.py @@ -1,20 +0,0 @@ -# Copyright (c) 2013 AnsibleWorks, Inc. -# -# This file is part of Ansible Commander. -# -# Ansible Commander is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3 of the License. -# -# Ansible Commander is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible Commander. If not, see . - -try: - from local_settings import * -except ImportError: - from defaults import * diff --git a/lib/settings/defaults.py b/lib/settings/defaults.py index 3b8ffb1e5c..83e0a29dd0 100644 --- a/lib/settings/defaults.py +++ b/lib/settings/defaults.py @@ -1,19 +1,5 @@ # Copyright (c) 2013 AnsibleWorks, Inc. -# -# This file is part of Ansible Commander. -# -# Ansible Commander is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3 of the License. -# -# Ansible Commander is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible Commander. If not, see . - +# All Rights Reserved. import os import sys @@ -88,7 +74,9 @@ STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) -STATIC_ROOT = os.path.join(BASE_DIR, 'public', 'static') # FIXME: Is this where we want it? +# Absolute filesystem path to the directory where static file are collected via +# the collectstatic command. +STATIC_ROOT = os.path.join(BASE_DIR, 'public', 'static') # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/dev/howto/static-files/ @@ -156,6 +144,34 @@ INSTALLED_APPS = ( INTERNAL_IPS = ('127.0.0.1',) +# Email address that error messages come from. +SERVER_EMAIL = 'root@localhost' + +# Default email address to use for various automated correspondence from +# the site managers. +DEFAULT_FROM_EMAIL = 'webmaster@localhost' + +# Subject-line prefix for email messages send with django.core.mail.mail_admins +# or ...mail_managers. Make sure to include the trailing space. +EMAIL_SUBJECT_PREFIX = '[AnsibleWorks] ' + +# The email backend to use. For possible shortcuts see django.core.mail. +# The default is to use the SMTP backend. +# Third-party backends can be specified by providing a Python path +# to a module that defines an EmailBackend class. +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' + +# Host for sending email. +EMAIL_HOST = 'localhost' + +# Port for sending email. +EMAIL_PORT = 25 + +# Optional SMTP authentication information for EMAIL_HOST. +EMAIL_HOST_USER = '' +EMAIL_HOST_PASSWORD = '' +EMAIL_USE_TLS = False + # Use Django-devserver if installed. try: import devserver diff --git a/lib/settings/development.py b/lib/settings/development.py new file mode 100644 index 0000000000..12cd117549 --- /dev/null +++ b/lib/settings/development.py @@ -0,0 +1,26 @@ +# Copyright (c) 2013 AnsibleWorks, Inc. +# All Rights Reserved. + +# Development settings for Ansible Commander project. + +from defaults import * + +# If a local_settings.py file is present here, use it and ignore the global +# settings. Normally local settings would only be present during development. +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: + # Otherwise, rely on the global settings file specified in the environment, + # defaulting to /etc/ansibleworks/settings.py. + try: + settings_file = os.environ.get('ANSIBLEWORKS_SETTINGS_FILE', + '/etc/ansibleworks/settings.py') + execfile(settings_file) + except IOError: + pass diff --git a/lib/settings/production.py b/lib/settings/production.py new file mode 100644 index 0000000000..e054ef32b3 --- /dev/null +++ b/lib/settings/production.py @@ -0,0 +1,39 @@ +# Copyright (c) 2013 AnsibleWorks, Inc. +# All Rights Reserved. + +# Production settings for Ansible Commander project. + +from defaults import * + +DEBUG = False +TEMPLATE_DEBUG = DEBUG + +# Clear database settings to force production environment to define them. +DATABASES = {} + +# Clear the secret key to force production environment to define it. +SECRET_KEY = None + +# 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 +ALLOWED_HOSTS = [] + +# If a local_settings.py file is present here, use it and ignore the global +# settings. Normally, local settings would only be present during development. +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: + # Otherwise, rely on the global settings file specified in the environment, + # defaulting to /etc/ansibleworks/settings.py. + try: + settings_file = os.environ.get('ANSIBLEWORKS_SETTINGS_FILE', + '/etc/ansibleworks/settings.py') + execfile(settings_file) + except IOError: + pass diff --git a/lib/wsgi.py b/lib/wsgi.py index f82d18ee28..8a391c5137 100644 --- a/lib/wsgi.py +++ b/lib/wsgi.py @@ -25,7 +25,7 @@ https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/ import os -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lib.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lib.settings.production') from django.core.wsgi import get_wsgi_application application = get_wsgi_application() diff --git a/manage.py b/manage.py index 866aa7cf9b..7b4c1dc3c1 100755 --- a/manage.py +++ b/manage.py @@ -1,5 +1,10 @@ #!/usr/bin/env python +import os + if __name__ == '__main__': + # Since this manage.py will only be used when running from a source + # checkout, default to using the development settings. + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lib.settings.development') from lib import manage manage() diff --git a/requirements.txt b/requirements.txt index 6f7b5d2769..4d337bd330 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ ipython==0.13.1 pexpect==2.4 # psycopg2==2.4.6 python-dateutil==1.5 -PyYAML==3.10 +# PyYAML==3.10 South==0.7.6 requests djangorestframework