From 799a32e74cae64b73295db387d81e07380998681 Mon Sep 17 00:00:00 2001 From: AnsibleGuy Date: Sat, 17 Feb 2024 21:31:15 +0100 Subject: [PATCH] added debug-mode setting --- docs/source/usage/troubleshooting.rst | 15 +++++++++++++++ src/ansible-webui/aw/config/defaults.py | 1 + src/ansible-webui/aw/config/form_metadata.py | 4 ++++ src/ansible-webui/aw/model/system.py | 6 ++++-- src/ansible-webui/aw/settings.py | 2 +- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/source/usage/troubleshooting.rst b/docs/source/usage/troubleshooting.rst index dee53e7..f29d1f1 100644 --- a/docs/source/usage/troubleshooting.rst +++ b/docs/source/usage/troubleshooting.rst @@ -20,6 +20,21 @@ It will be beneficial for the troubleshooting process if we find out in which th |ts_sys_ov| +---- + +Debugging +********* + +You can enable the debug mode at the :code:`System - Config` page. + +If that is not possible you can alternatively set the :code:`AW_ENV` environmental variable to :code:`dev`. + +This debug mode **SHOULD ONLY BE ENABLED TEMPORARILY**! It could possibly open attack vectors. + +You might need to restart the application to apply this setting. + +---- + Job Execution ************* diff --git a/src/ansible-webui/aw/config/defaults.py b/src/ansible-webui/aw/config/defaults.py index 9f266d4..2cff744 100644 --- a/src/ansible-webui/aw/config/defaults.py +++ b/src/ansible-webui/aw/config/defaults.py @@ -45,4 +45,5 @@ def _get_defaults_docker(var: str) -> any: 'session_timeout': 12 * 60 * 60, # 12h 'path_ansible_config': _get_existing_ansible_config_file(), 'path_ssh_known_hosts': _get_defaults_docker('path_ssh_known_hosts'), + 'debug': False, } diff --git a/src/ansible-webui/aw/config/form_metadata.py b/src/ansible-webui/aw/config/form_metadata.py index 7bfda45..545dfeb 100644 --- a/src/ansible-webui/aw/config/form_metadata.py +++ b/src/ansible-webui/aw/config/form_metadata.py @@ -36,6 +36,7 @@ 'session_timeout': 'Timeout for WebUI login-sessions', 'path_ansible_config': 'Ansible Config-File', 'path_ssh_known_hosts': 'SSH Known-Hosts File', + 'debug': 'Debug Mode', # env-vars 'timezone': 'Timezone', 'db': 'Database', @@ -100,6 +101,9 @@ '/intro_configuration.html#configuration-file">Ansible config-file to use', 'path_ssh_known_hosts': 'Path to a SSH known_hosts file to use', + 'debug': 'Enable Debug-mode. Do not enable permanent on production systems! ' + 'It can possibly open attack vectors. ' + 'You might need to restart the application to apply this setting', } } } diff --git a/src/ansible-webui/aw/model/system.py b/src/ansible-webui/aw/model/system.py index 2715bdf..6441c16 100644 --- a/src/ansible-webui/aw/model/system.py +++ b/src/ansible-webui/aw/model/system.py @@ -2,15 +2,16 @@ from django.db import models from django.core.exceptions import ObjectDoesNotExist -from aw.model.base import BaseModel +from aw.model.base import BaseModel, CHOICES_BOOL from aw.config.defaults import CONFIG_DEFAULTS from aw.config.environment import check_aw_env_var_is_set +from aw.utils.deployment import deployment_dev class SystemConfig(BaseModel): form_fields = [ 'path_run', 'path_play', 'path_log', 'timezone', 'run_timeout', 'session_timeout', 'path_ansible_config', - 'path_ssh_known_hosts', + 'path_ssh_known_hosts', 'debug', ] # NOTE: 'AW_DB' is needed to get this config from DB and 'AW_SECRET' cannot be saved because of security breach api_fields_write = form_fields @@ -31,6 +32,7 @@ class SystemConfig(BaseModel): path_ssh_known_hosts = models.CharField( max_length=500, default=CONFIG_DEFAULTS['path_ssh_known_hosts'], null=True, blank=True, ) + debug = models.BooleanField(default=CONFIG_DEFAULTS['debug'] or deployment_dev(), choices=CHOICES_BOOL) @classmethod def get_set_env_vars(cls) -> list: diff --git a/src/ansible-webui/aw/settings.py b/src/ansible-webui/aw/settings.py index 59e823c..b3e008d 100644 --- a/src/ansible-webui/aw/settings.py +++ b/src/ansible-webui/aw/settings.py @@ -20,7 +20,7 @@ BASE_DIR / 'aw' / 'templates/' ] -DEBUG = deployment_dev() +DEBUG = deployment_dev() or config['debug'] DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' X_FRAME_OPTIONS = 'SAMEORIGIN'