diff --git a/defaults/main.yml b/defaults/main.yml index ee92efb7..1746675a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -128,18 +128,14 @@ horizon_system_user_home: "/var/lib/{{ horizon_system_user_name }}" ## Service Type and Data horizon_service_region: RegionOne horizon_service_name: horizon - -## Database info -horizon_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" -horizon_galera_address: "{{ galera_address | default('127.0.0.1') }}" -horizon_galera_database: dash -horizon_galera_user: dash -horizon_galera_use_ssl: "{{ galera_use_ssl | default(False) }}" -horizon_galera_ssl_ca_cert: "{{ galera_ssl_ca_cert | default('/etc/ssl/certs/galera-ca.pem') }}" - ## Session configuration # Specifies the timespan in seconds inactivity, until a user is considered as # logged out +horizon_session_engine: 'django.contrib.sessions.backends.cache' +horizon_session_caches: + default: + BACKEND: 'django.core.cache.backends.memcached.MemcachedCache' + LOCATION: "{{ memcached_servers.split(',') }}" horizon_session_timeout: 1800 ## Horizon Help URL Path @@ -393,7 +389,6 @@ horizon_listen_ports: horizon_pip_packages: - horizon - - PyMySQL - python-memcached # Specific pip packages provided by the user diff --git a/releasenotes/notes/session_engine-54753c41d355e34e.yaml b/releasenotes/notes/session_engine-54753c41d355e34e.yaml new file mode 100644 index 00000000..49cffd22 --- /dev/null +++ b/releasenotes/notes/session_engine-54753c41d355e34e.yaml @@ -0,0 +1,11 @@ +--- +upgrade: + - | + `SESSION_ENGINE` has been changed to memcached by default. So that + horizon do not require it's own database for storing session + information anymore. `horizon_galera_*` variables has no effect now. +features: + - | + Added variables `horizon_session_engine` and `horizon_session_caches` + which can be used to configure horizon session engine and a backend + for it. diff --git a/tasks/db_setup.yml b/tasks/db_setup.yml deleted file mode 100644 index 7a0120d4..00000000 --- a/tasks/db_setup.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -# Copyright 2019, VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file 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. - -# WARNING: -# This file is maintained in the openstack-ansible-tests repository. -# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/sync/tasks/db_setup.yml -# If you need to modify this file, update the one in the openstack-ansible-tests -# repository. Once it merges there, the changes will automatically be proposed to -# all the repositories which use it. - -- name: Setup Database Service (MariaDB) - delegate_to: "{{ _oslodb_setup_host }}" - tags: - - common-mariadb - block: - - name: Create database for service - mysql_db: - name: "{{ item.name }}" - loop: "{{ _oslodb_databases }}" - no_log: true - - - name: Grant access to the database for the service - mysql_user: - name: "{{ item.1.username }}" - password: "{{ item.1.password }}" - host: "{{ item.1.host | default('%') }}" - priv: "{{ item.0.name }}.*:{{ item.1.priv | default('ALL') }}" - append_privs: yes - loop: "{{ _oslodb_databases | subelements('users') }}" - no_log: true diff --git a/tasks/horizon_db_sync.yml b/tasks/horizon_db_sync.yml deleted file mode 100644 index 5a8892eb..00000000 --- a/tasks/horizon_db_sync.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -# Copyright 2014, Rackspace US, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file 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. - -- name: Perform a horizon DB sync - command: "{{ horizon_manage }} migrate --noinput" - become: yes - become_user: "{{ horizon_system_user_name }}" - changed_when: false - -- name: Register DB session cleanup cron - cron: - name: "Clear out expired sessions" - minute: "{{ 58 | random(seed=inventory_hostname, start=2) }}" - hour: "21" - job: "{{ horizon_manage }} clearsessions" - user: "{{ horizon_system_user_name }}" - state: present diff --git a/tasks/horizon_post_install.yml b/tasks/horizon_post_install.yml index 0d6ecaf9..7de18b22 100644 --- a/tasks/horizon_post_install.yml +++ b/tasks/horizon_post_install.yml @@ -119,3 +119,13 @@ register: async_compress_static_files async: 600 poll: 0 + +- name: Register DB session cleanup cron + cron: + name: "Clear out expired sessions" + minute: "{{ 58 | random(seed=inventory_hostname, start=2) }}" + hour: "21" + job: "{{ horizon_manage }} clearsessions" + user: "{{ horizon_system_user_name }}" + state: present + when: inventory_hostname == ansible_play_hosts[0] diff --git a/tasks/main.yml b/tasks/main.yml index 4920b4cb..6c71ce5f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -39,19 +39,6 @@ tags: - always -- import_tasks: db_setup.yml - when: inventory_hostname == ansible_play_hosts[0] - vars: - _oslodb_setup_host: "{{ horizon_db_setup_host }}" - _oslodb_databases: - - name: "{{ horizon_galera_database }}" - users: - - username: "{{ horizon_galera_user }}" - password: "{{ horizon_container_mysql_password }}" - tags: - - common-db - - horizon-config - - import_tasks: horizon_pre_install.yml tags: - horizon-install @@ -64,11 +51,6 @@ tags: - horizon-config -- import_tasks: horizon_db_sync.yml - when: inventory_hostname == ansible_play_hosts[0] - tags: - - horizon-config - - import_tasks: horizon_ssl_self_signed.yml when: - horizon_enable_ssl | bool diff --git a/templates/horizon-manage.py.j2 b/templates/horizon-manage.py.j2 index f74c6216..53e328b4 100644 --- a/templates/horizon-manage.py.j2 +++ b/templates/horizon-manage.py.j2 @@ -13,11 +13,8 @@ # under the License. import os -import pymysql import sys -pymysql.install_as_MySQLdb() - from django.core.management import execute_from_command_line # noqa if __name__ == "__main__": diff --git a/templates/horizon_django.wsgi.j2 b/templates/horizon_django.wsgi.j2 index 9766ba2e..b7fbe818 100644 --- a/templates/horizon_django.wsgi.j2 +++ b/templates/horizon_django.wsgi.j2 @@ -1,12 +1,9 @@ import logging import os -import pymysql import sys from django.core.wsgi import get_wsgi_application from django.conf import settings -pymysql.install_as_MySQLdb() - # Add this file path to sys.path in order to import settings sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../..'))) os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings' diff --git a/templates/horizon_local_settings.py.j2 b/templates/horizon_local_settings.py.j2 index e5fd2025..07c42e48 100644 --- a/templates/horizon_local_settings.py.j2 +++ b/templates/horizon_local_settings.py.j2 @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import os -import pymysql from django.utils.translation import ugettext_lazy as _ @@ -9,8 +8,6 @@ from horizon.utils import secret_key from openstack_dashboard import exceptions from openstack_dashboard.settings import HORIZON_CONFIG -pymysql.install_as_MySQLdb() - DEBUG = {{ debug }} TEMPLATE_DEBUG = DEBUG @@ -142,28 +139,10 @@ SECRET_KEY = secret_key.generate_or_read_from_file( # We recommend you use memcached for development; otherwise after every reload # of the django development server, you will have to login again. To use # memcached set CACHES to something like -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', - 'LOCATION': {{ memcached_servers.split(',') }} - } -} +CACHES = {{ horizon_session_caches }} # Set the session engine configuration: -SESSION_ENGINE = "django.contrib.sessions.backends.cached_db" -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'HOST': '{{ horizon_galera_address }}', - 'NAME': '{{ horizon_galera_database }}', - 'USER': '{{ horizon_galera_user }}', - 'PASSWORD': '{{ horizon_container_mysql_password }}', - 'default-character-set': 'utf8' - {% if horizon_galera_use_ssl | bool -%} - ,'ssl-ca': '{{ horizon_galera_ssl_ca_cert }}' - {% endif -%} - }, -} +SESSION_ENGINE = '{{ horizon_session_engine }}' # Send email to the console by default EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/vars/debian.yml b/vars/debian.yml index 2b5ec0dc..3d5fe61c 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -35,7 +35,6 @@ horizon_service_distro_packages: - python3-django-openstack-auth - python3-django-horizon - python3-memcache - - python3-pymysql horizon_apache_conf: "/etc/apache2/apache2.conf" horizon_apache_security_conf: "/etc/apache2/conf-available/security.conf" diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 6ce6f642..f47c3ec7 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -42,7 +42,6 @@ horizon_service_distro_packages: - openstack-octavia-ui - python-django-horizon - python-memcached - - python-PyMySQL horizon_apache_conf: "/etc/httpd/conf/httpd.conf" horizon_apache_security_conf: "{{ horizon_apache_conf }}" diff --git a/vars/suse.yml b/vars/suse.yml index 8f3035f9..21f35611 100644 --- a/vars/suse.yml +++ b/vars/suse.yml @@ -43,7 +43,6 @@ horizon_service_distro_packages: - openstack-horizon-plugin-trove-ui - python-horizon - python-memcached - - python-PyMySQL # SUSE does not currently have packages for the following dashboards horizon_enable_heat_ui: False