mirror of https://github.com/jumpserver/jumpserver
perf: update ansible env set
parent
2faad88b78
commit
49378d1f13
|
@ -12,6 +12,10 @@ class CeleryBaseService(BaseService):
|
|||
@property
|
||||
def cmd(self):
|
||||
print('\n- Start Celery as Distributed Task Queue: {}'.format(self.queue.capitalize()))
|
||||
os.environ.setdefault('PYTHONPATH', settings.APPS_DIR)
|
||||
os.environ.setdefault('LC_ALL', 'en_US.UTF-8')
|
||||
os.environ.setdefault('LANG', 'en_US.UTF-8')
|
||||
os.environ.setdefault('PYTHONOPTIMIZE', '1')
|
||||
|
||||
if os.getuid() == 0:
|
||||
os.environ.setdefault('C_FORCE_ROOT', '1')
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
from ops.ansible.cleaner import WorkPostRunCleaner, cleanup_post_run
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from ops.ansible.cleaner import WorkPostRunCleaner
|
||||
|
||||
|
||||
class BaseRunner(WorkPostRunCleaner):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.runner_params = kwargs
|
||||
self.clean_workspace = kwargs.pop("clean_workspace", True)
|
||||
self.setup_env()
|
||||
|
||||
@staticmethod
|
||||
def setup_env():
|
||||
ansible_config_path = os.path.join(settings.APPS_DIR, 'libs', 'ansible', 'ansible.cfg')
|
||||
ansible_modules_path = os.path.join(settings.APPS_DIR, 'libs', 'ansible', 'modules')
|
||||
os.environ.setdefault('ANSIBLE_FORCE_COLOR', 'True')
|
||||
os.environ.setdefault('ANSIBLE_CONFIG', ansible_config_path)
|
||||
os.environ.setdefault('ANSIBLE_LIBRARY', ansible_modules_path)
|
||||
|
||||
@classmethod
|
||||
def kill_precess(cls, pid):
|
||||
|
|
|
@ -8,9 +8,6 @@ __all__ = ['AnsibleNativeRunner']
|
|||
|
||||
|
||||
class AnsibleNativeRunner(BaseRunner):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@classmethod
|
||||
def kill_precess(cls, pid):
|
||||
return kill_ansible_ssh_process(pid)
|
||||
|
|
10
jms
10
jms
|
@ -20,16 +20,6 @@ sys.path.insert(0, APP_DIR)
|
|||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jumpserver.settings")
|
||||
django.setup()
|
||||
|
||||
ansible_config_path = os.path.join(APP_DIR, 'libs', 'ansible', 'ansible.cfg')
|
||||
ansible_modules_path = os.path.join(APP_DIR, 'libs', 'ansible', 'modules')
|
||||
os.environ.setdefault('LC_ALL', 'en_US.UTF-8')
|
||||
os.environ.setdefault('LANG', 'en_US.UTF-8')
|
||||
os.environ.setdefault('PYTHONOPTIMIZE', '1')
|
||||
os.environ.setdefault('ANSIBLE_FORCE_COLOR', 'True')
|
||||
os.environ.setdefault('ANSIBLE_CONFIG', ansible_config_path)
|
||||
os.environ.setdefault('ANSIBLE_LIBRARY', ansible_modules_path)
|
||||
os.environ.setdefault('PYTHONPATH', APP_DIR)
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue