diff options
Diffstat (limited to 'ansible/roles/ansible-vvp-templates/files/configmaps')
8 files changed, 1581 insertions, 0 deletions
diff --git a/ansible/roles/ansible-vvp-templates/files/configmaps/ci-configmap.yaml b/ansible/roles/ansible-vvp-templates/files/configmaps/ci-configmap.yaml new file mode 100644 index 0000000..05c15d2 --- /dev/null +++ b/ansible/roles/ansible-vvp-templates/files/configmaps/ci-configmap.yaml @@ -0,0 +1,321 @@ +# -*- encoding: utf-8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: ci-settings + namespace: default +data: + uwsgi.ini: | + [uwsgi] + uwsgi-socket = :80 + http = :8282 + plugin = python + chdir = /app + module = web.wsgi:application + master = True + pidfile = /tmp/project-master.pid + vacuum = True + max-requests = 5000 + enable-threads = True + stats = 0.0.0.0:9000 + stats-http = True + __init__.py: | + import os + from datetime import datetime + + # With this file at web/settings/__init__.py, we need three applications of + # dirname() to find the project root. + PROJECT_PATH = os.path.realpath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + LOGS_PATH = os.path.join(PROJECT_PATH, "logs") + + ICE_ENVIRONMENT = os.environ['ICE_ENVIRONMENT'] + PROGRAM_NAME_URL_PREFIX = os.environ['PROGRAM_NAME_URL_PREFIX'] + + # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ + SECRET_KEY = os.environ["SECRET_KEY"] + + # https://docs.djangoproject.com/en/1.10/ref/settings/#allowed-hosts + # Anything in the Host header that does not match our expected domain should + # raise SuspiciousOperation exception. + ALLOWED_HOSTS = ['*'] + + if ICE_ENVIRONMENT == 'production': + DEBUG = False + + EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' + EMAIL_HOST = os.environ.get('ICE_EMAIL_HOST') + EMAIL_HOST_PASSWORD = os.environ['EMAIL_HOST_PASSWORD'] + EMAIL_HOST_USER = os.environ['EMAIL_HOST_USER'] + EMAIL_PORT = os.environ['EMAIL_PORT'] + else: + DEBUG = True + EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + + + # Note: Only SSL email backends are allowed + EMAIL_USE_SSL = True + + REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework_jwt.authentication.JSONWebTokenAuthentication', + ), + 'PAGE_SIZE': 10, + # Use Django's standard `django.contrib.auth` permissions, + # or allow read-only access for unauthenticated users. + 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',), + } + APPEND_SLASH = False + + # Application definition + + INSTALLED_APPS = [ + + 'django.contrib.auth', + 'django.contrib.contenttypes', # required by d.c.admin + 'django.contrib.sessions', # required by d.c.admin + 'django.contrib.messages', # required by d.c.admin + 'django.contrib.staticfiles', + 'django.contrib.admin', # django admin site + 'rest_framework', + 'iceci.apps.IceCiConfig', + ] + + MIDDLEWARE_CLASSES = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + ] + + ROOT_URLCONF = 'web.urls' + + TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [PROJECT_PATH + '/web/templates'], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', # required by d.c.admin + 'django.contrib.messages.context_processors.messages', # required by d.c.admin + ], + }, + }, + ] + + WSGI_APPLICATION = 'web.wsgi.application' + + # Database + # https://docs.djangoproject.com/en/1.9/ref/settings/#databases + + DATABASES = { + 'default': { # CI DB details. + 'NAME': '/app/ice_ci_db.db' , + 'ENGINE': 'django.db.backends.sqlite3', + 'TEST_NAME': '/app/ice_ci_db.db', + }, + } + SINGLETONE_DB = { + 'default': { # CI DB details. + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get('CI_DB_NAME', 'ice_ci_db'), + 'USER': os.environ.get('CI_DB_USER', 'iceci'), + 'PASSWORD': os.environ.get('CI_DB_PASSWORD', 'Aa123456'), + 'HOST': os.environ.get('CI_DB_HOST', 'localhost'), + 'PORT': os.environ.get('CI_DB_PORT', '5433'), + }, + 'em_db': { # ICE DB details. + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get('EM_DB_NAME', 'icedb'), + 'USER': os.environ.get('EM_DB_USER', 'iceuser'), + 'PASSWORD': os.environ.get('EM_DB_PASSWORD', 'Aa123456'), + 'HOST': os.environ.get('EM_DB_HOST', 'localhost'), + 'PORT': os.environ.get('EM_DB_PORT', '5433'), + }, + 'cms_db': { # ICE CMS details. + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get('CMS_DB_NAME', 'icecmsdb'), + 'USER': os.environ.get('CMS_DB_USER', 'icecmsuser'), + 'PASSWORD': os.environ.get('CMS_DB_PASSWORD', 'Aa123456'), + 'HOST': os.environ.get('CMS_DB_HOST', 'localhost'), + 'PORT': os.environ.get('CMS_DB_PORT', '5433'), + } + } + + # Password validation + # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators + + AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, + ] + + + # Internationalization + # https://docs.djangoproject.com/en/1.9/topics/i18n/ + + LANGUAGE_CODE = 'en-us' + + TIME_ZONE = 'UTC' + + USE_I18N = True + + USE_L10N = True + + USE_TZ = False + + + # Static files (CSS, JavaScript, Images) + # https://docs.djangoproject.com/en/1.9/howto/static-files/ + STATIC_ROOT = os.environ['STATIC_ROOT'] + STATIC_URL = '/static/' + + LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { # All possible attributes are: https://docs.python.org/3/library/logging.html#logrecord-attributes + 'verbose': { + 'format': '%(asctime)s %(levelname)s %(module)s %(filename)s:%(lineno)d %(process)d %(thread)d %(message)s' + }, + 'simple': { + 'format': '%(asctime)s %(levelname)s %(filename)s:%(lineno)d %(message)s' + }, + }, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + 'formatter': 'simple' + }, + 'file1': { + 'level': 'INFO', # handler will ignore DEBUG (only process INFO, WARN, ERROR, CRITICAL, FATAL) + 'class': 'logging.FileHandler', + 'filename': os.environ.get('ICE_ICE_LOGGER_PATH', LOGS_PATH) + 'vvp-info.log', + 'formatter': 'verbose' + }, + 'file2': { + 'level': 'DEBUG', + 'class': 'logging.FileHandler', + 'filename': os.environ.get('ICE_ICE_LOGGER_PATH', LOGS_PATH) + 'vvp-debug.log', + 'formatter': 'verbose' + }, + 'file3': { + 'level': 'ERROR', + 'class': 'logging.FileHandler', + 'filename': os.environ.get('ICE_ICE_LOGGER_PATH', LOGS_PATH) + 'vvp-requests.log', + 'formatter': 'verbose' + }, + 'file4': { + 'level': 'ERROR', + 'class': 'logging.FileHandler', + 'filename': os.environ.get('ICE_ICE_LOGGER_PATH', LOGS_PATH) + 'vvp-db.log', + 'formatter': 'verbose' + } + }, + 'loggers': { + 'vvp-ci.logger': { + 'handlers': ['file1', 'file2', 'file3', 'file4','console'], + 'level': os.getenv('ICE_ICE_LOGGER_LEVEL', 'DEBUG'), + }, + 'django': { + 'handlers': ['console'], + 'level': os.getenv('ICE_DJANGO_LOGGER_LEVEL', 'DEBUG'), + }, + 'django.request': { + 'handlers': ['file3'], + 'level': os.getenv('ICE_ICE_REQUESTS_LOGGER_LEVEL', 'ERROR'), + }, + 'django.db.backends': { + 'handlers': ['file4'], + 'level': os.getenv('ICE_ICE_DB_LOGGER_LEVEL', 'ERROR'), + } + } + } + + + ############################# + # ICE-CI Related Configuration + ############################# + ICE_CONTACT_FROM_ADDRESS = os.getenv('ICE_CONTACT_FROM_ADDRESS') + ICE_CONTACT_EMAILS = list(os.getenv('ICE_CONTACT_EMAILS') + ICE_CI_ENVIRONMENT_NAME = os.getenv('ICE_CI_ENVIRONMENT_NAME', 'Dev') # Dev / Docker / Staging + ICE_EM_URL = "{domain}/{prefix}".format(domain=os.environ['ICE_EM_DOMAIN_NAME'], prefix=PROGRAM_NAME_URL_PREFIX) + ICE_PORTAL_URL = os.environ['ICE_DOMAIN'] + EM_REST_URL = ICE_EM_URL + '/v1/engmgr/' + + #Number of test results presented in admin page. Illegal values: '0' or 'Null' + NUMBER_OF_TEST_RESULTS = int(os.getenv('NUMBER_OF_TEST_RESULTS', '30')) + ICE_BUILD_REPORT_NUM = os.getenv('ICE_BUILD_REPORT_NUM',"{:%Y-%m-%d-%H-%M-%S}".format(datetime.now())) + IS_JUMP_STATE=os.getenv('IS_JUMP_STATE', "True") + DATABASE_TYPE = 'sqlite' + + # FIXME: Does this authentication scheme actually gain us anything? What's the + # threat model + WEBHOOK_TOKEN = os.environ['SECRET_WEBHOOK_TOKEN'] + + # The authentication token and URL needed for us to issue requests to the GitLab API. + GITLAB_TOKEN = os.environ['SECRET_GITLAB_AUTH_TOKEN'] + GITLAB_URL = "http://gitlab/" + + JENKINS_URL = "http://jenkins:8080/" + JENKINS_USERNAME = "admin" + JENKINS_PASSWORD = os.environ['SECRET_JENKINS_PASSWORD'] + + AWS_S3_HOST = os.environ['S3_HOST'] + AWS_S3_PORT = int(os.environ['S3_PORT']) + AWS_S3_CUSTOM_DOMAIN = os.environ['S3_HOST'] + AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID'] + AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY'] diff --git a/ansible/roles/ansible-vvp-templates/files/configmaps/cms-configmap.yaml b/ansible/roles/ansible-vvp-templates/files/configmaps/cms-configmap.yaml new file mode 100644 index 0000000..4aedece --- /dev/null +++ b/ansible/roles/ansible-vvp-templates/files/configmaps/cms-configmap.yaml @@ -0,0 +1,477 @@ +# -*- encoding: utf-8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: cms-settings + namespace: default +data: + uwsgi.ini: | + [uwsgi] + uwsgi-socket = :80 + plugin = python + chdir = /srv + module = cms.wsgi:application + master = True + pidfile = /tmp/project-master.pid + vacuum = True + max-requests = 5000 + enable-threads = True + stats = 0.0.0.0:9000 + stats-http = True + __init__.py: | + from __future__ import absolute_import, unicode_literals + import os + from cms.envbool import envbool + + from django import VERSION as DJANGO_VERSION + from django.utils.translation import ugettext_lazy as _ + from boto.s3.connection import OrdinaryCallingFormat + + + ###################### + # MEZZANINE SETTINGS # + ###################### + + # The following settings are already defined with default values in + # the ``defaults.py`` module within each of Mezzanine's apps, but are + # common enough to be put here, commented out, for conveniently + # overriding. Please consult the settings documentation for a full list + # of settings Mezzanine implements: + # http://mezzanine.jupo.org/docs/configuration.html#default-settings + + # Controls the ordering and grouping of the admin menu. + # + # ADMIN_MENU_ORDER = ( + # ("Content", ("pages.Page", "blog.BlogPost", + # "generic.ThreadedComment", (_("Media Library"), "media-library"),)), + # ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")), + # ("Users", ("auth.User", "auth.Group",)), + # ) + + # A three item sequence, each containing a sequence of template tags + # used to render the admin dashboard. + # + # DASHBOARD_TAGS = ( + # ("blog_tags.quick_blog", "mezzanine_tags.app_list"), + # ("comment_tags.recent_comments",), + # ("mezzanine_tags.recent_actions",), + # ) + + # A sequence of templates used by the ``page_menu`` template tag. Each + # item in the sequence is a three item sequence, containing a unique ID + # for the template, a label for the template, and the template path. + # These templates are then available for selection when editing which + # menus a page should appear in. Note that if a menu template is used + # that doesn't appear in this setting, all pages will appear in it. + + # PAGE_MENU_TEMPLATES = ( + # (1, _("Top navigation bar"), "pages/menus/dropdown.html"), + # (2, _("Left-hand tree"), "pages/menus/tree.html"), + # (3, _("Footer"), "pages/menus/footer.html"), + # ) + + # A sequence of fields that will be injected into Mezzanine's (or any + # library's) models. Each item in the sequence is a four item sequence. + # The first two items are the dotted path to the model and its field + # name to be added, and the dotted path to the field class to use for + # the field. The third and fourth items are a sequence of positional + # args and a dictionary of keyword args, to use when creating the + # field instance. When specifying the field class, the path + # ``django.models.db.`` can be omitted for regular Django model fields. + # + # EXTRA_MODEL_FIELDS = ( + # ( + # # Dotted path to field. + # "mezzanine.blog.models.BlogPost.image", + # # Dotted path to field class. + # "somelib.fields.ImageField", + # # Positional args for field class. + # (_("Image"),), + # # Keyword args for field class. + # {"blank": True, "upload_to": "blog"}, + # ), + # # Example of adding a field to *all* of Mezzanine's content types: + # ( + # "mezzanine.pages.models.Page.another_field", + # "IntegerField", # 'django.db.models.' is implied if path is omitted. + # (_("Another name"),), + # {"blank": True, "default": 1}, + # ), + # ) + + # Setting to turn on featured images for blog posts. Defaults to False. + # + # BLOG_USE_FEATURED_IMAGE = True + + # If True, the django-modeltranslation will be added to the + # INSTALLED_APPS setting. + USE_MODELTRANSLATION = False + + + ######################## + # MAIN DJANGO SETTINGS # + ######################## + + # 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 = ['*'] + + # Set UTC time zone: + TIME_ZONE = 'UTC' + USE_TZ = True + + # Local time zone for this installation. Choices can be found here: + # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name + # although not all choices may be available on all operating systems. + # On Unix systems, a value of None will cause Django to use the same + # timezone as the operating system. + # If running in a Windows environment this must be set to the same as your + # system time zone. + TIME_ZONE = 'UTC' + + # If you set this to True, Django will use timezone-aware datetimes. + USE_TZ = True + + # Language code for this installation. All choices can be found here: + # http://www.i18nguy.com/unicode/language-identifiers.html + LANGUAGE_CODE = "en" + + # Supported languages + LANGUAGES = ( + ('en', _('English')), + ) + + ENVIRONMENT = os.environ['ENVIRONMENT'] + + # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ + SECRET_KEY = os.environ["SECRET_KEY"] + + # A boolean that turns on/off debug mode. When set to ``True``, stack traces + # are displayed for error pages. Should always be set to ``False`` in + # production. Best set to ``True`` in local_settings.py + DEBUG = envbool('DJANGO_DEBUG_MODE', False) + + # Note: Only SSL email backends are allowed + EMAIL_USE_SSL = True + + # Whether a user's session cookie expires when the Web browser is closed. + SESSION_EXPIRE_AT_BROWSER_CLOSE = True + + SITE_ID = 1 + + # If you set this to False, Django will make some optimizations so as not + # to load the internationalization machinery. + USE_I18N = False + + AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",) + + # The numeric mode to set newly-uploaded files to. The value should be + # a mode you'd pass directly to os.chmod. + FILE_UPLOAD_PERMISSIONS = 0o644 + + + ############# + # DATABASES # + ############# + + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ['PGDATABASE'], + 'USER': os.environ['PGUSER'], + 'PASSWORD': os.environ['PGPASSWORD'], + 'HOST': os.environ['PGHOST'], + 'PORT': os.environ['PGPORT'], + } + } + + + ######### + # PATHS # + ######### + + # Full filesystem path to the project. + PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__)) + PROJECT_APP = os.path.basename(PROJECT_APP_PATH) + PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH) + + # Every cache key will get prefixed with this value - here we set it to + # the name of the directory the project is in to try and use something + # project specific. + CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP + + # Package/module name to import the root urlpatterns from for the project. + ROOT_URLCONF = 'cms.urls' + + TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [ + os.path.join(PROJECT_ROOT, "templates") + ], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + "django.template.context_processors.debug", + "django.template.context_processors.i18n", + "django.template.context_processors.static", + "django.template.context_processors.media", + "django.template.context_processors.request", + "django.template.context_processors.tz", + "mezzanine.conf.context_processors.settings", + "mezzanine.pages.context_processors.page", + ], + "builtins": [ + "mezzanine.template.loader_tags", + ], + }, + }, + ] + + if DJANGO_VERSION < (1, 9): + del TEMPLATES[0]["OPTIONS"]["builtins"] + + + ################ + # APPLICATIONS # + ################ + + INSTALLED_APPS = ( + "mezzanine_api", + "rest_framework", + "rest_framework_swagger", + "oauth2_provider", + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.redirects", + "django.contrib.sessions", + "django.contrib.sites", + "django.contrib.sitemaps", + "django.contrib.staticfiles", + "mezzanine.boot", + "mezzanine.conf", + "mezzanine.core", + "mezzanine.generic", + "mezzanine.pages", + "mezzanine.blog", + "mezzanine.forms", + "mezzanine.galleries", + "mezzanine.twitter", + # "mezzanine.accounts", + # "mezzanine.mobile", + "cms" , + "storages", + ) + + # List of middleware classes to use. Order is important; in the request phase, + # these middleware classes will be applied in the order given, and in the + # response phase the middleware will be applied in reverse order. + MIDDLEWARE_CLASSES = ( + "mezzanine.core.middleware.UpdateCacheMiddleware", + "mezzanine_api.middleware.ApiMiddleware", + 'django.contrib.sessions.middleware.SessionMiddleware', + # Uncomment if using internationalisation or localisation + # 'django.middleware.locale.LocaleMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + + "mezzanine.core.request.CurrentRequestMiddleware", + "mezzanine.core.middleware.RedirectFallbackMiddleware", + "mezzanine.core.middleware.TemplateForDeviceMiddleware", + "mezzanine.core.middleware.TemplateForHostMiddleware", + "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware", + "mezzanine.core.middleware.SitePermissionMiddleware", + "mezzanine.pages.middleware.PageMiddleware", + "mezzanine.core.middleware.FetchFromCacheMiddleware", + ) + + # Store these package names here as they may change in the future since + # at the moment we are using custom forks of them. + PACKAGE_NAME_FILEBROWSER = "filebrowser_safe" + PACKAGE_NAME_GRAPPELLI = "grappelli_safe" + + ######################### + # OPTIONAL APPLICATIONS # + ######################### + + # These will be added to ``INSTALLED_APPS``, only if available. + OPTIONAL_APPS = ( + "debug_toolbar", + "django_extensions", + "compressor", + PACKAGE_NAME_FILEBROWSER, + PACKAGE_NAME_GRAPPELLI, + ) + + ##################### + # REST API SETTINGS # + ##################### + try: + from mezzanine_api.settings import * + except ImportError: + pass + + + ################## + # LOCAL SETTINGS # + ################## + + # Allow any settings to be defined in local_settings.py which should be + # ignored in your version control system allowing for settings to be + # defined per ma chine. + + # Instead of doing "from .local_settings import *", we use exec so that + # local_settings has full access to everything defined in this module. + # Also force into sys.modules so it's visible to Django's autoreload. + + f = os.path.join(PROJECT_APP_PATH, "local_settings/__init__.py") + if os.path.exists(f): + import sys + import imp + module_name = "%s.local_settings" % PROJECT_APP + module = imp.new_module(module_name) + module.__file__ = f + sys.modules[module_name] = module + exec(open(f, "rb").read()) + + + #################### + # DYNAMIC SETTINGS # + #################### + + # set_dynamic_settings() will rewrite globals based on what has been + # defined so far, in order to provide some better defaults where + # applicable. We also allow this settings module to be imported + # without Mezzanine installed, as the case may be when using the + # fabfile, where setting the dynamic settings below isn't strictly + # required. + try: + from mezzanine.utils.conf import set_dynamic_settings + except ImportError: + pass + else: + set_dynamic_settings(globals()) + + # default settings for mezzanine + NEVERCACHE_KEY = os.getenv('CMS_NEVERCACHE_KEY', ''), + # Application User + CMS_APP_USER = os.getenv('CMS_APP_USER') + CMS_APP_USER_PASSWORD = os.getenv('CMS_APP_USER_PASSWORD') + CMS_APP_USER_MAIL = os.getenv('CMS_APP_USER_MAIL') + # Client App (EM) + CMS_APP_CLIENT_ID = os.getenv('CMS_APP_CLIENT_ID') + CMS_APP_CLIENT_SECRET = os.getenv('CMS_APP_CLIENT_SECRET') + CMS_APP_NAME = 'Engagement_Manager_App' + REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] = ( + 'rest_framework.renderers.JSONRenderer', + ) + + # S3 configuration for static resources storage and media upload + + # used by our custom storage.py + MEDIA_BUCKET = "cms-media" + STATIC_BUCKET = "cms-static" + + # django-storages configuration + AWS_S3_HOST = os.environ['S3_HOST'] + AWS_S3_PORT = int(os.environ['S3_PORT']) + AWS_S3_CUSTOM_DOMAIN = os.environ['S3_HOST'] + AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID'] + AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY'] + AWS_AUTO_CREATE_BUCKET = True + AWS_PRELOAD_METADATA = True + + # Set by custom subclass. + # AWS_STORAGE_BUCKET_NAME = "em-static" + AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat() + DEFAULT_FILE_STORAGE = 'cms.settings.storage.S3MediaStorage' + STATICFILES_STORAGE = 'cms.settings.storage.S3StaticStorage' + + # These seem to have no effect even when we don't override with custom_domain? + STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, STATIC_BUCKET) + MEDIA_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, MEDIA_BUCKET) + + STATIC_ROOT = os.environ['STATIC_ROOT'] + + storage.py: | + """ + storage.py + + In order to make Django store trusted static files and untrusted media + (user-uploaded) files in separate s3 buckets, we must create two different + storage classes. + + https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/ + http://www.leehodgkinson.com/blog/my-mezzanine-s3-setup/ + + """ + + # FIXME this module never changes so might not need not be kept in a + # configmap. Also it is (almost) the same as what we use in em; that does + # not use S3BotoStorageMixin. + + # There is a newer storage based on boto3 but that doesn't support changing + # the HOST, as we need to for non-amazon s3 services. It does support an + # "endpoint"; setting AWS_S3_ENDPOINT_URL may cause it to work. + from storages.backends.s3boto import S3BotoStorage + from filebrowser_safe.storage import S3BotoStorageMixin + from django.conf import settings + + + # NOTE for some reason, collectstatic uploads to bucket/location but the + # urls constructed are domain/location + class S3StaticStorage(S3BotoStorage, S3BotoStorageMixin): + custom_domain = '%s/%s' % (settings.AWS_S3_HOST, settings.STATIC_BUCKET) + bucket_name = settings.STATIC_BUCKET + # location = ... + + + class S3MediaStorage(S3BotoStorage, S3BotoStorageMixin): + custom_domain = '%s/%s' % (settings.AWS_S3_HOST, settings.MEDIA_BUCKET) + bucket_name = settings.MEDIA_BUCKET + # location = ... diff --git a/ansible/roles/ansible-vvp-templates/files/configmaps/em-configmap.yaml b/ansible/roles/ansible-vvp-templates/files/configmaps/em-configmap.yaml new file mode 100644 index 0000000..79ad7b2 --- /dev/null +++ b/ansible/roles/ansible-vvp-templates/files/configmaps/em-configmap.yaml @@ -0,0 +1,442 @@ +# -*- encoding: utf-8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: em-settings + namespace: default +data: + uwsgi.ini: | + [uwsgi] + uwsgi-socket = :80 + plugin = python + chdir = /srv + module = vvp.wsgi:application + master = True + pidfile = /tmp/project-master.pid + vacuum = True + max-requests = 5000 + enable-threads = True + stats = 0.0.0.0:9000 + stats-http = True + __init__.py: | + """ + Django settings for VVP project. + + Environment variables that must exist: + + ENVIRONMENT + SECRET_KEY + SECRET_WEBHOOK_TOKEN + SECRET_GITLAB_AUTH_TOKEN + SECRET_JENKINS_PASSWORD + SECRET_CMS_APP_CLIENT_ID + SECRET_CMS_APP_CLIENT_SECRET + + Environment variables that must exist in production: + + EMAIL_HOST + EMAIL_HOST_PASSWORD + EMAIL_HOST_USER + EMAIL_PORT + + """ + + import os + from vvp.settings.envbool import envbool + from corsheaders.defaults import default_headers + from boto.s3.connection import OrdinaryCallingFormat + import datetime + + # With this file at ice/settings/__init__.py, we need three applications of + # dirname() to find the project root. + import engagementmanager + PROJECT_PATH = os.path.dirname(os.path.dirname(engagementmanager.__file__)) + LOGS_PATH = os.path.join(PROJECT_PATH, "logs") + + ENVIRONMENT = os.environ['ENVIRONMENT'] + PROGRAM_NAME_URL_PREFIX = os.environ['PROGRAM_NAME_URL_PREFIX'] + + # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ + SECRET_KEY = os.environ["SECRET_KEY"] + + # https://docs.djangoproject.com/en/1.10/ref/settings/#allowed-hosts + # Anything in the Host header that does not match our expected domain should + # raise SuspiciousOperation exception. + ALLOWED_HOSTS = ['*'] + + DEBUG = envbool('DJANGO_DEBUG_MODE', False) + + if ENVIRONMENT == 'production': + EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' + EMAIL_HOST = os.environ['EMAIL_HOST'] + EMAIL_HOST_PASSWORD = os.environ['EMAIL_HOST_PASSWORD'] + EMAIL_HOST_USER = os.environ['EMAIL_HOST_USER'] + EMAIL_PORT = os.environ['EMAIL_PORT'] + else: + EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + + # Note: Only SSL email backends are allowed + EMAIL_USE_SSL = True + + REST_FRAMEWORK = { + # Use Django's standard `django.contrib.auth` permissions, + # or allow read-only access for unauthenticated users. + 'EXCEPTION_HANDLER': 'engagementmanager.utils.exception_handler.ice_exception_handler', + 'PAGE_SIZE': 10, + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.IsAuthenticated', + ), + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.SessionAuthentication', + 'rest_framework.authentication.BasicAuthentication', + 'rest_framework_jwt.authentication.JSONWebTokenAuthentication', + ), + 'DEFAULT_PARSER_CLASSES': ( + 'engagementmanager.rest.parsers.XSSJSONParser', + 'engagementmanager.rest.parsers.XSSFormParser', + 'engagementmanager.rest.parsers.XSSMultiPartParser', + ) + } + + JWT_AUTH = { + 'JWT_AUTH_HEADER_PREFIX': 'token', + 'JWT_ALGORITHM': 'HS256', + 'JWT_EXPIRATION_DELTA': datetime.timedelta(days=1), + 'JWT_DECODE_HANDLER': 'engagementmanager.utils.authentication.ice_jwt_decode_handler', + } + + APPEND_SLASH = False + + # Application definition + INSTALLED_APPS = [ + 'django.contrib.auth', # required by d.c.admin + 'corsheaders', + 'django.contrib.contenttypes', # required by d.c.admin + 'django.contrib.sessions', # required by d.c.admin + 'django.contrib.messages', # required by d.c.admin + 'django.contrib.staticfiles', + 'django.contrib.admin', # django admin site + 'rest_framework', + 'engagementmanager.apps.EngagementmanagerConfig', + 'validationmanager.apps.ValidationmanagerConfig', + ] + + MIDDLEWARE_CLASSES = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', # required by d.c.admin + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'corsheaders.middleware.CorsMiddleware', + ] + + ROOT_URLCONF = 'vvp.urls' + + TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [PROJECT_PATH + '/web/templates'], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', # required by d.c.admin + 'django.contrib.messages.context_processors.messages', # required by d.c.admin + ], + }, + }, + ] + + WSGI_APPLICATION = 'vvp.wsgi.application' + + + # Database + # https://docs.djangoproject.com/en/1.9/ref/settings/#databases + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ['PGDATABASE'], + 'USER': os.environ['PGUSER'], + 'PASSWORD': os.environ['PGPASSWORD'], + 'HOST': os.environ['PGHOST'], + 'PORT': os.environ['PGPORT'], + } + } + + + # Password validation + # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators + AUTH_PASSWORD_VALIDATORS = [ + {'NAME': 'django.contrib.auth.password_validation.%s' % s} for s in [ + 'UserAttributeSimilarityValidator', + 'MinimumLengthValidator', + 'CommonPasswordValidator', + 'NumericPasswordValidator', + ]] + + + # Internationalization + # https://docs.djangoproject.com/en/1.9/topics/i18n/ + LANGUAGE_CODE = 'en-us' + TIME_ZONE = 'UTC' + USE_I18N = True + USE_L10N = True + USE_TZ = True + + CORS_ALLOW_HEADERS = default_headers + ('ICE-USER-ID',) + + # Static files (CSS, JavaScript, Images) + # https://docs.djangoproject.com/en/1.9/howto/static-files/ + STATIC_ROOT = os.environ['STATIC_ROOT'] + + + LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { # All possible attributes are: https://docs.python.org/3/library/logging.html#logrecord-attributes + 'verbose': { + 'format': '%(asctime)s %(levelname)s %(name)s %(module)s %(lineno)d %(process)d %(thread)d %(message)s' + }, + 'simple': { + 'format': '%(asctime)s %(levelname)s %(name)s %(message)s' + }, + }, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + 'formatter': 'simple' + }, + 'vvp-info.log': { + 'level': 'INFO', # handler will ignore DEBUG (only process INFO, WARN, ERROR, CRITICAL, FATAL) + 'class': 'logging.FileHandler', + 'filename': os.path.join(LOGS_PATH, 'vvp-info.log'), + 'formatter': 'verbose' + }, + 'vvp-debug.log': { + 'level': 'DEBUG', + 'class': 'logging.FileHandler', + 'filename': os.path.join(LOGS_PATH, 'vvp-debug.log'), + 'formatter': 'verbose' + }, + 'vvp-requests.log': { + 'level': 'ERROR', + 'class': 'logging.FileHandler', + 'filename': os.path.join(LOGS_PATH, 'vvp-requests.log'), + 'formatter': 'verbose' + }, + 'vvp-db.log': { + 'level': 'ERROR', + 'class': 'logging.FileHandler', + 'filename': os.path.join(LOGS_PATH, 'vvp-db.log'), + 'formatter': 'verbose', + }, + }, + 'loggers': { + 'vvp.logger': { + 'handlers': ['vvp-info.log', 'vvp-debug.log', 'vvp-requests.log', 'vvp-db.log', 'console'], + 'level': 'DEBUG' if DEBUG else 'INFO', + }, + 'django': { + 'handlers': ['console'], + 'level': 'INFO' if DEBUG else 'ERROR', + }, + 'django.request': { + 'handlers': ['vvp-requests.log', 'console'], + 'level': 'INFO' if DEBUG else 'ERROR', + }, + 'django.db.backends': { + 'handlers': ['vvp-db.log', 'console'], + 'level': 'DEBUG' if DEBUG else 'ERROR', + 'propagate': False, + }, + # silence the hundred lines of useless "missing variable in template" + # complaints per admin pageview. + 'django.template': { + 'level': 'DEBUG', + 'handlers': ['vvp-info.log', 'vvp-debug.log', 'console'], + 'propagate': False, + }, + } + } + + + ############################# + # VVP Related Configuration + ############################# + CONTACT_FROM_ADDRESS = os.getenv('CONTACT_FROM_ADDRESS', 'dummy@example.com') + CONTACT_EMAILS = [s.strip() for s in os.getenv('CONTACT_EMAILS', 'dummy@example.com') + DOMAIN = os.getenv('EM_DOMAIN_NAME') + TOKEN_EXPIRATION_IN_HOURS = 48 + DAILY_SCHEDULED_JOB_HOUR = 20 + NUMBER_OF_POLLED_ACTIVITIES = 5 + TEMP_PASSWORD_EXPIRATION_IN_HOURS = 48 + # This is the DNS name pointing to the private-network ip of the host machine + # running (a haproxy that points to) (an nginx frontend for) this app + API_DOMAIN = 'em' + + # The authentication token needed by Jenkins or Gitlab to issue webhook updates + # to us. This is a "secret" shared by Jenkins and Django. It must be part of + # the URL path component for the Jenkins webhook in ValidationManager to accept + # a notification. It should be a set of random URL-path-safe characters, with + # no slash '/'. + # FIXME: Does this authentication scheme actually gain us anything? What's the + # threat model + WEBHOOK_TOKEN = os.environ['SECRET_WEBHOOK_TOKEN'] + + # The authentication token and URL needed for us to issue requests to the GitLab API. + GITLAB_TOKEN = os.environ['SECRET_GITLAB_AUTH_TOKEN'] + GITLAB_URL = "http://gitlab/" + + JENKINS_URL = "http://jenkins:8080/" + JENKINS_USERNAME = "admin" + JENKINS_PASSWORD = os.environ['SECRET_JENKINS_PASSWORD'] + + IS_CL_CREATED_ON_REVIEW_STATE = envbool('IS_CL_CREATED_ON_REVIEW_STATE', False) # Options: True, False + IS_SIGNAL_ENABLED = envbool('IS_SIGNAL_ENABLED', True) + RECENT_ENG_TTL = 3 # In days + CMS_URL = "http://cms/api/" + CMS_APP_CLIENT_ID = os.environ['SECRET_CMS_APP_CLIENT_ID'] + CMS_APP_CLIENT_SECRET = os.environ['SECRET_CMS_APP_CLIENT_SECRET'] + + # slack integration + SLACK_API_TOKEN = os.environ['SLACK_API_TOKEN'] + ENGAGEMENTS_CHANNEL = os.getenv('ENGAGEMENTS_CHANNEL', '') + ENGAGEMENTS_NOTIFICATIONS_CHANNEL = os.getenv('ENGAGEMENTS_NOTIFICATIONS_CHANNEL:', '') + DEVOPS_CHANNEL = os.getenv('DEVOPS_CHANNEL', '') + DEVOPS_NOTIFICATIONS_CHANNEL = os.getenv('DEVOPS_NOTIFICATIONS_CHANNEL', '') + + # S3 configuration for static resources storage and media upload + + # used by our custom storage.py + MEDIA_BUCKET = "em-media" + STATIC_BUCKET = "em-static" + + # django-storages configuration + AWS_S3_HOST = os.environ['S3_HOST'] + AWS_S3_PORT = int(os.environ['S3_PORT']) + AWS_S3_CUSTOM_DOMAIN = os.environ['S3_HOST'] + AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID'] + AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY'] + AWS_AUTO_CREATE_BUCKET = True + AWS_PRELOAD_METADATA = True + + # Set by custom subclass. + # AWS_STORAGE_BUCKET_NAME = "em-static" + AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat() + DEFAULT_FILE_STORAGE = 'vvp.settings.storage.S3MediaStorage' + STATICFILES_STORAGE = 'vvp.settings.storage.S3StaticStorage' + + # These seem to have no effect even when we don't override with custom_domain? + STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, STATIC_BUCKET) + MEDIA_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, MEDIA_BUCKET) + + STATIC_ROOT = os.environ['STATIC_ROOT'] + + storage.py: | + """ + storage.py + + In order to make Django store trusted static files and untrusted media + (user-uploaded) files in separate s3 buckets, we must create two different + storage classes. + + https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/ + http://www.leehodgkinson.com/blog/my-mezzanine-s3-setup/ + + """ + + # FIXME this module never changes so might not need not be kept in a + # configmap. Also it is (almost) the same as what we use in cms. + + # There is a newer storage based on boto3 but that doesn't support changing + # the HOST, as we need to for non-amazon s3 services. It does support an + # "endpoint"; setting AWS_S3_ENDPOINT_URL may cause it to work. + from storages.backends.s3boto import S3BotoStorage + from django.conf import settings + + + # NOTE for some reason, collectstatic uploads to bucket/location but the + # urls constructed are domain/location + class S3StaticStorage(S3BotoStorage): + custom_domain = '%s/%s' % (settings.AWS_S3_HOST, settings.STATIC_BUCKET) + bucket_name = settings.STATIC_BUCKET + # location = ... + + + class S3MediaStorage(S3BotoStorage): + custom_domain = '%s/%s' % (settings.AWS_S3_HOST, settings.MEDIA_BUCKET) + bucket_name = settings.MEDIA_BUCKET + # location = ... + + envbool.py: | + """ + envbool.py + + Return which environment is currently running on (to setting.py). + + """ + import os + + + def envbool(key, default=False, unknown=True): + """Return a boolean value based on that of an environment variable. + + Environment variables have no native boolean type. They are always strings, and may be empty or + unset (which differs from empty.) Furthermore, notions of what is "truthy" in shell script + differ from that of python. + + This function converts environment variables to python boolean True or False in + case-insensitive, expected ways to avoid pitfalls: + + "True", "true", and "1" become True + "False", "false", and "0" become False + unset or empty becomes False by default (toggle with 'default' parameter.) + any other value becomes True by default (toggle with 'unknown' parameter.) + + """ + return { + 'true': True, '1': True, # 't': True, + 'false': False, '0': False, # 'f': False. + '': default, + }.get(os.getenv(key, '').lower(), unknown) diff --git a/ansible/roles/ansible-vvp-templates/files/configmaps/nginx-cms-configmap.yaml b/ansible/roles/ansible-vvp-templates/files/configmaps/nginx-cms-configmap.yaml new file mode 100644 index 0000000..89adf32 --- /dev/null +++ b/ansible/roles/ansible-vvp-templates/files/configmaps/nginx-cms-configmap.yaml @@ -0,0 +1,74 @@ +# -*- encoding: utf-8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: nginx-cms-conf + namespace: default +data: + nginx.conf: | + error_log /dev/stdout warn; + + http { + access_log /dev/stdout; + upstream cms_upstream { + server cms-uwsgi:80; + } + + server { + listen 80 ; + charset utf-8; + client_max_body_size 75M; # adjust to taste + + location / { + uwsgi_pass cms_upstream; + include /etc/nginx/uwsgi_params; + } + } + server { + listen 9000; + location /status { + stub_status; + } + } + } #http + events { + worker_connections 4096; ## Default: 1024 + } diff --git a/ansible/roles/ansible-vvp-templates/files/configmaps/nginx-em-configmap.yaml b/ansible/roles/ansible-vvp-templates/files/configmaps/nginx-em-configmap.yaml new file mode 100644 index 0000000..0d7b279 --- /dev/null +++ b/ansible/roles/ansible-vvp-templates/files/configmaps/nginx-em-configmap.yaml @@ -0,0 +1,75 @@ +# -*- encoding: utf-8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: nginx-em-conf + namespace: default +data: + nginx.conf: | + error_log /dev/stdout warn; + + http { + access_log /dev/stdout; + upstream em_upstream { + server em-uwsgi:80; + } + + server { + listen 80; + charset utf-8; + client_max_body_size 75M; # adjust to taste + + location / { + uwsgi_pass em_upstream; + include /etc/nginx/uwsgi_params; + } + } + + server { + listen 9000; + location /status { + stub_status; + } + } + } #http + events { + worker_connections 4096; ## Default: 1024 + } diff --git a/ansible/roles/ansible-vvp-templates/files/configmaps/portal-nginx-configmap.yaml b/ansible/roles/ansible-vvp-templates/files/configmaps/portal-nginx-configmap.yaml new file mode 100644 index 0000000..4d0e4e8 --- /dev/null +++ b/ansible/roles/ansible-vvp-templates/files/configmaps/portal-nginx-configmap.yaml @@ -0,0 +1,66 @@ +# -*- encoding: utf-8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: portal-nginx-config + namespace: default +data: + file: | + pid /nginx.pid; + error_log /dev/stdout warn; + + http { + access_log /dev/stdout; + server { + listen 0.0.0.0:8181; + + location / { + include /etc/nginx/mime.types; + root /usr/share/nginx/html/; + } + + } + + } + + events { + worker_connections 4096; + } diff --git a/ansible/roles/ansible-vvp-templates/files/configmaps/postgresql-conf-configmap.yaml b/ansible/roles/ansible-vvp-templates/files/configmaps/postgresql-conf-configmap.yaml new file mode 100644 index 0000000..999c1ca --- /dev/null +++ b/ansible/roles/ansible-vvp-templates/files/configmaps/postgresql-conf-configmap.yaml @@ -0,0 +1,65 @@ +# -*- encoding: utf-8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: postgresql-conf + namespace: default +data: + postgresql.conf: | + # + # initdb defaults + # + listen_addresses = '*' # what IP address(es) to listen on; + max_connections = 100 # (change requires restart) + shared_buffers = 32MB # min 128kB + datestyle = 'iso, mdy' + lc_messages = 'en_US.UTF-8' # locale for system error message + lc_monetary = 'en_US.UTF-8' # locale for monetary formatting + lc_numeric = 'en_US.UTF-8' # locale for number formatting + lc_time = 'en_US.UTF-8' # locale for time formatting + default_text_search_config = 'pg_catalog.english' + log_line_prefix = 'user=%u,db=%d ' + # + # our customizations + # + dynamic_shared_memory_type = posix + log_timezone = 'UTC' + timezone = 'UTC' diff --git a/ansible/roles/ansible-vvp-templates/files/configmaps/postgresql-initdb-configmap.yaml b/ansible/roles/ansible-vvp-templates/files/configmaps/postgresql-initdb-configmap.yaml new file mode 100644 index 0000000..e6f272e --- /dev/null +++ b/ansible/roles/ansible-vvp-templates/files/configmaps/postgresql-initdb-configmap.yaml @@ -0,0 +1,61 @@ +# -*- encoding: utf-8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/engagementmgr +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: postgresql-initdb + namespace: default +data: + # docker-entrypoint.sh supports sql scripts but we need to expand variables. + cms_db.sh: | + # sourced, not executed, by docker-entrypoint.sh (/bin/bash) + + # defaults + : ${ICE_CMS_DB_USER:="icecmsuser"} + : ${ICE_CMS_DB_NAME:="icecmsdb"} + : ${ICE_CMS_DB_PASSWORD:="na"} + + psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<- EOF + CREATE USER ${ICE_CMS_DB_USER} WITH CREATEDB PASSWORD '${ICE_CMS_DB_PASSWORD}'; + CREATE DATABASE ${ICE_CMS_DB_NAME} WITH OWNER ${ICE_CMS_DB_USER} ENCODING 'utf-8'; + EOF + link_postgresql.sh: | + # sourced, not executed, by docker-entrypoint.sh (/bin/bash) + ln -sf /etc/postgresql/conf.d/postgresql.conf "${PGDATA}"/postgresql.conf |