Skip to content

Commit

Permalink
added debug-mode setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Feb 17, 2024
1 parent 516f7b3 commit 799a32e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
15 changes: 15 additions & 0 deletions docs/source/usage/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
*************

Expand Down
1 change: 1 addition & 0 deletions src/ansible-webui/aw/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
4 changes: 4 additions & 0 deletions src/ansible-webui/aw/config/form_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -100,6 +101,9 @@
'/intro_configuration.html#configuration-file">Ansible config-file</a> to use',
'path_ssh_known_hosts': 'Path to a <a href="https://en.wikibooks.org/wiki/OpenSSH/'
'Client_Configuration_Files#~/.ssh/known_hosts">SSH known_hosts file</a> 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',
}
}
}
6 changes: 4 additions & 2 deletions src/ansible-webui/aw/model/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/ansible-webui/aw/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 799a32e

Please sign in to comment.