mirror of https://github.com/jumpserver/jumpserver
feat: 增加 DEBUG_ANSIBLE 配置项支持打印 Ansible 详细日志
parent
f686f9f107
commit
819853eae4
|
@ -186,6 +186,7 @@ class Config(dict):
|
||||||
'BOOTSTRAP_TOKEN': '',
|
'BOOTSTRAP_TOKEN': '',
|
||||||
'DEBUG': False,
|
'DEBUG': False,
|
||||||
'DEBUG_DEV': False,
|
'DEBUG_DEV': False,
|
||||||
|
'DEBUG_ANSIBLE': False,
|
||||||
'LOG_LEVEL': 'DEBUG',
|
'LOG_LEVEL': 'DEBUG',
|
||||||
'LOG_DIR': os.path.join(PROJECT_DIR, 'data', 'logs'),
|
'LOG_DIR': os.path.join(PROJECT_DIR, 'data', 'logs'),
|
||||||
'DB_ENGINE': 'mysql',
|
'DB_ENGINE': 'mysql',
|
||||||
|
|
|
@ -53,6 +53,8 @@ BOOTSTRAP_TOKEN = CONFIG.BOOTSTRAP_TOKEN
|
||||||
DEBUG = CONFIG.DEBUG
|
DEBUG = CONFIG.DEBUG
|
||||||
# SECURITY WARNING: If you run with debug turned on, more debug msg with be log
|
# SECURITY WARNING: If you run with debug turned on, more debug msg with be log
|
||||||
DEBUG_DEV = CONFIG.DEBUG_DEV
|
DEBUG_DEV = CONFIG.DEBUG_DEV
|
||||||
|
# SECURITY WARNING: If you run ansible task with debug turned on, more debug msg with be log
|
||||||
|
DEBUG_ANSIBLE = CONFIG.DEBUG_ANSIBLE
|
||||||
|
|
||||||
# Absolute url for some case, for example email link
|
# Absolute url for some case, for example email link
|
||||||
SITE_URL = CONFIG.SITE_URL
|
SITE_URL = CONFIG.SITE_URL
|
||||||
|
|
|
@ -5,6 +5,7 @@ import ansible_runner
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from .callback import DefaultCallback
|
from .callback import DefaultCallback
|
||||||
|
from ..utils import get_ansible_log_verbosity
|
||||||
|
|
||||||
|
|
||||||
class CommandInBlackListException(Exception):
|
class CommandInBlackListException(Exception):
|
||||||
|
@ -37,8 +38,7 @@ class AdHocRunner:
|
||||||
|
|
||||||
def run(self, verbosity=0, **kwargs):
|
def run(self, verbosity=0, **kwargs):
|
||||||
self.check_module()
|
self.check_module()
|
||||||
if verbosity is None and settings.DEBUG:
|
verbosity = get_ansible_log_verbosity(verbosity)
|
||||||
verbosity = 1
|
|
||||||
|
|
||||||
if not os.path.exists(self.project_dir):
|
if not os.path.exists(self.project_dir):
|
||||||
os.mkdir(self.project_dir, 0o755)
|
os.mkdir(self.project_dir, 0o755)
|
||||||
|
@ -70,8 +70,7 @@ class PlaybookRunner:
|
||||||
self.cb = callback
|
self.cb = callback
|
||||||
|
|
||||||
def run(self, verbosity=0, **kwargs):
|
def run(self, verbosity=0, **kwargs):
|
||||||
if verbosity is None and settings.DEBUG:
|
verbosity = get_ansible_log_verbosity(verbosity)
|
||||||
verbosity = 1
|
|
||||||
|
|
||||||
ansible_runner.run(
|
ansible_runner.run(
|
||||||
private_data_dir=self.project_dir,
|
private_data_dir=self.project_dir,
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
# ~*~ coding: utf-8 ~*~
|
# ~*~ coding: utf-8 ~*~
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from common.utils import get_logger, make_dirs
|
||||||
|
|
||||||
from common.utils import get_logger, get_object_or_none, make_dirs
|
|
||||||
from orgs.utils import org_aware_func
|
|
||||||
from jumpserver.const import PROJECT_DIR
|
from jumpserver.const import PROJECT_DIR
|
||||||
|
|
||||||
from .models import AdHoc, CeleryTask
|
|
||||||
from .const import DEFAULT_PASSWORD_RULES
|
|
||||||
|
|
||||||
logger = get_logger(__file__)
|
logger = get_logger(__file__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,3 +21,11 @@ def get_task_log_path(base_path, task_id, level=2):
|
||||||
make_dirs(os.path.dirname(path), exist_ok=True)
|
make_dirs(os.path.dirname(path), exist_ok=True)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def get_ansible_log_verbosity(verbosity=0):
|
||||||
|
if settings.DEBUG_ANSIBLE:
|
||||||
|
return 10
|
||||||
|
if verbosity is None and settings.DEBUG:
|
||||||
|
return 1
|
||||||
|
return verbosity
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue