mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-05-01 21:03:59 +00:00
fix: 修复 ansible receptor playbook 无法执行的问题
This commit is contained in:
parent
3e46d72ba3
commit
2b05fd5276
@ -618,7 +618,7 @@ class Config(dict):
|
|||||||
|
|
||||||
# Ansible Receptor
|
# Ansible Receptor
|
||||||
'ANSIBLE_RECEPTOR_ENABLE': True,
|
'ANSIBLE_RECEPTOR_ENABLE': True,
|
||||||
'ANSIBLE_RECEPTOR_SOCK_PATH': 'data/share/control.sock'
|
'ANSIBLE_RECEPTOR_SOCK_PATH': '{}/data/share/control.sock'.format(PROJECT_DIR)
|
||||||
}
|
}
|
||||||
|
|
||||||
old_config_map = {
|
old_config_map = {
|
||||||
|
@ -87,6 +87,7 @@ class AdHocRunner:
|
|||||||
|
|
||||||
class PlaybookRunner:
|
class PlaybookRunner:
|
||||||
def __init__(self, inventory, playbook, project_dir='/tmp/', callback=None):
|
def __init__(self, inventory, playbook, project_dir='/tmp/', callback=None):
|
||||||
|
|
||||||
self.id = uuid.uuid4()
|
self.id = uuid.uuid4()
|
||||||
self.inventory = inventory
|
self.inventory = inventory
|
||||||
self.playbook = playbook
|
self.playbook = playbook
|
||||||
@ -96,7 +97,16 @@ class PlaybookRunner:
|
|||||||
self.cb = callback
|
self.cb = callback
|
||||||
self.envs = {}
|
self.envs = {}
|
||||||
|
|
||||||
|
def copy_playbook(self):
|
||||||
|
entry = os.path.basename(self.playbook)
|
||||||
|
playbook_dir = os.path.dirname(self.playbook)
|
||||||
|
project_playbook_dir = os.path.join(self.project_dir, "project")
|
||||||
|
shutil.copytree(playbook_dir, project_playbook_dir)
|
||||||
|
self.playbook = entry
|
||||||
|
|
||||||
def run(self, verbosity=0, **kwargs):
|
def run(self, verbosity=0, **kwargs):
|
||||||
|
self.copy_playbook()
|
||||||
|
|
||||||
verbosity = get_ansible_log_verbosity(verbosity)
|
verbosity = get_ansible_log_verbosity(verbosity)
|
||||||
private_env = safe_join(self.project_dir, 'env')
|
private_env = safe_join(self.project_dir, 'env')
|
||||||
if os.path.exists(private_env):
|
if os.path.exists(private_env):
|
||||||
|
@ -339,7 +339,9 @@ class JobExecution(JMSOrgBaseModel):
|
|||||||
)
|
)
|
||||||
elif self.current_job.type == Types.playbook:
|
elif self.current_job.type == Types.playbook:
|
||||||
runner = PlaybookRunner(
|
runner = PlaybookRunner(
|
||||||
self.inventory_path, self.current_job.playbook.entry
|
self.inventory_path,
|
||||||
|
self.current_job.playbook.entry,
|
||||||
|
self.private_dir
|
||||||
)
|
)
|
||||||
elif self.current_job.type == Types.upload_file:
|
elif self.current_job.type == Types.upload_file:
|
||||||
job_id = self.current_job.id
|
job_id = self.current_job.id
|
||||||
@ -522,7 +524,6 @@ class JobExecution(JMSOrgBaseModel):
|
|||||||
ssh_tunnel.local_gateway_clean(runner)
|
ssh_tunnel.local_gateway_clean(runner)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
||||||
unit_id_path = os.path.join(self.private_dir, "local.unitid")
|
unit_id_path = os.path.join(self.private_dir, "local.unitid")
|
||||||
if os.path.exists(unit_id_path):
|
if os.path.exists(unit_id_path):
|
||||||
with open(unit_id_path) as f:
|
with open(unit_id_path) as f:
|
||||||
|
2
jms
2
jms
@ -188,7 +188,7 @@ if __name__ == '__main__':
|
|||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"services", type=str, default='all', nargs="*",
|
"services", type=str, default='all', nargs="*",
|
||||||
choices=("all", "web", "task", "receptor"),
|
choices=("all", "web", "task"),
|
||||||
help="The service to start",
|
help="The service to start",
|
||||||
)
|
)
|
||||||
parser.add_argument('-d', '--daemon', nargs="?", const=True)
|
parser.add_argument('-d', '--daemon', nargs="?", const=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user