Compare commits

..

4 Commits

Author SHA1 Message Date
Bai
c49c394b5b perf: Update poetry.lock 2024-03-25 14:23:32 +08:00
wangruidong
a0f27a9476 fix: 修复 redis lock 导致 celery 异步任务卡住不执行的问题 2024-03-25 14:17:11 +08:00
Bai
5af6f89229 perf: Update poetry.lock 2024-03-22 17:24:21 +08:00
ibuler
adbd73182b fix: ansible playbook render and run in localhost 2024-03-22 17:05:56 +08:00
7 changed files with 32 additions and 20 deletions

1
GITSHA
View File

@@ -1 +0,0 @@
eb9f261459982d52c0e8844203ba95b7dd1741ee

View File

@@ -12,7 +12,7 @@ from sshtunnel import SSHTunnelForwarder
from assets.automations.methods import platform_automation_methods
from common.utils import get_logger, lazyproperty, is_openssh_format_key, ssh_pubkey_gen
from ops.ansible import JMSInventory, PlaybookRunner, DefaultCallback
from ops.ansible import JMSInventory, SuperPlaybookRunner, DefaultCallback
logger = get_logger(__name__)
@@ -269,7 +269,7 @@ class BasePlaybookManager:
if not playbook_path:
continue
runer = PlaybookRunner(
runer = SuperPlaybookRunner(
inventory_path,
playbook_path,
self.runtime_dir,

View File

@@ -8,7 +8,7 @@ __all__ = ['BASE_DIR', 'PROJECT_DIR', 'VERSION', 'CONFIG']
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.dirname(BASE_DIR)
VERSION = 'v3.10.6'
VERSION = '2.0.0'
CONFIG = ConfigManager.load_user_config()

View File

@@ -1,6 +1,7 @@
import os
import uuid
import shutil
import uuid
import ansible_runner
from django.conf import settings
from django.utils._os import safe_join
@@ -43,6 +44,9 @@ class AdHocRunner:
if not os.path.exists(self.project_dir):
os.mkdir(self.project_dir, 0o755)
private_env = safe_join(self.project_dir, 'env')
if os.path.exists(private_env):
shutil.rmtree(private_env)
ansible_runner.run(
timeout=self.timeout if self.timeout > 0 else None,
@@ -69,9 +73,13 @@ class PlaybookRunner:
if not callback:
callback = DefaultCallback()
self.cb = callback
self.envs = {}
def run(self, verbosity=0, **kwargs):
verbosity = get_ansible_log_verbosity(verbosity)
private_env = safe_join(self.project_dir, 'env')
if os.path.exists(private_env):
shutil.rmtree(private_env)
ansible_runner.run(
private_data_dir=self.project_dir,
@@ -81,11 +89,18 @@ class PlaybookRunner:
event_handler=self.cb.event_handler,
status_handler=self.cb.status_handler,
host_cwd=self.project_dir,
envvars=self.envs,
**kwargs
)
return self.cb
class SuperPlaybookRunner(PlaybookRunner):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.envs = {"LOCAL_CONNECTION_ENABLED": "1"}
class UploadFileRunner:
def __init__(self, inventory, job_id, dest_path, callback=None):
self.id = uuid.uuid4()

View File

@@ -9,7 +9,7 @@ from django.utils import timezone
from common.db.utils import safe_db_connection
from common.utils import get_logger, random_string
from ops.ansible import PlaybookRunner, JMSInventory
from ops.ansible import SuperPlaybookRunner, JMSInventory
from terminal.models import Applet, AppletHostDeployment
logger = get_logger(__name__)
@@ -114,7 +114,7 @@ class DeployAppletHostManager:
def _run_playbook(self, generate_playbook: callable, **kwargs):
inventory = self.generate_inventory()
playbook = generate_playbook()
runner = PlaybookRunner(
runner = SuperPlaybookRunner(
inventory=inventory, playbook=playbook, project_dir=self.run_dir
)
return runner.run(**kwargs)

18
poetry.lock generated
View File

@@ -480,7 +480,7 @@ description = "Radically simple IT automation"
optional = false
python-versions = ">=3.9"
files = [
{file = "ansible-2.14.1.2.zip", hash = "sha256:813b39d8e03d5ea23b47703b3ba4d0372f68141b33e2b1be28deb6ad28b31c73"},
{file = "v2.14.1.4.zip", hash = "sha256:1805e06391223ac6198229a18f501f0e001e66c3b334cb7c5061e0ac810297d6"},
]
[package.dependencies]
@@ -492,7 +492,7 @@ resolvelib = ">=0.5.3,<0.9.0"
[package.source]
type = "url"
url = "https://github.com/jumpserver/ansible/releases/download/v2.14.1.2/ansible-2.14.1.2.zip"
url = "https://github.com/jumpserver/ansible/archive/refs/tags/v2.14.1.4.zip"
[[package]]
name = "ansible-runner"
@@ -6402,26 +6402,24 @@ reference = "tsinghua"
[[package]]
name = "redis"
version = "4.6.0"
version = "5.0.3"
description = "Python client for Redis database and key-value store"
optional = false
python-versions = ">=3.7"
files = [
{file = "redis-4.6.0-py3-none-any.whl", hash = "sha256:e2b03db868160ee4591de3cb90d40ebb50a90dd302138775937f6a42b7ed183c"},
{file = "redis-4.6.0.tar.gz", hash = "sha256:585dc516b9eb042a619ef0a39c3d7d55fe81bdb4df09a52c9cdde0d07bf1aa7d"},
{file = "v5.0.3.zip", hash = "sha256:2580c49b393568c11e8e14419558afd658edd9e9c74371d63613874bfe2c31c4"},
]
[package.dependencies]
async-timeout = {version = ">=4.0.2", markers = "python_full_version <= \"3.11.2\""}
async-timeout = {version = ">=4.0.3", markers = "python_full_version < \"3.11.3\""}
[package.extras]
hiredis = ["hiredis (>=1.0.0)"]
ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)"]
[package.source]
type = "legacy"
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
reference = "tsinghua"
type = "url"
url = "https://github.com/jumpserver-dev/redis-py/archive/refs/tags/v5.0.3.zip"
[[package]]
name = "requests"
@@ -7869,4 +7867,4 @@ reference = "tsinghua"
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "9f9294b5efb21a24625429dddb084c8d7f53b4d9d7d41c534d249bc9ed512905"
content-hash = "e1a6ab7c94316ee4542c13aefb118278e28a7ca2c118ecb5715343adee0c094d"

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "jumpserver"
version = "v3.10.6"
version = "v3.9"
description = "广受欢迎的开源堡垒机"
authors = ["ibuler <ibuler@qq.com>"]
license = "GPLv3"
@@ -11,7 +11,7 @@ python = "^3.11"
cython = "3.0.0"
aiofiles = "23.1.0"
amqp = "5.1.1"
ansible-core = { url = "https://github.com/jumpserver/ansible/releases/download/v2.14.1.2/ansible-2.14.1.2.zip" }
ansible-core = { url = "https://github.com/jumpserver/ansible/archive/refs/tags/v2.14.1.4.zip" }
ansible = "7.1.0"
ansible-runner = "2.3.3"
asn1crypto = "1.5.1"
@@ -125,7 +125,7 @@ pymysql = "1.1.0"
django-redis = "5.3.0"
python-redis-lock = "4.0.0"
pyopenssl = "23.2.0"
redis = "4.6.0"
redis = { url = "https://github.com/jumpserver-dev/redis-py/archive/refs/tags/v5.0.3.zip" }
pymongo = "4.4.1"
pyfreerdp = "0.0.2"
ipython = "8.14.0"