diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index 8af82e875..7534683b2 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -618,7 +618,7 @@ class Config(dict): # Ansible Receptor '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 = { diff --git a/apps/ops/ansible/runner.py b/apps/ops/ansible/runner.py index ad5899683..e468de3e2 100644 --- a/apps/ops/ansible/runner.py +++ b/apps/ops/ansible/runner.py @@ -87,6 +87,7 @@ class AdHocRunner: class PlaybookRunner: def __init__(self, inventory, playbook, project_dir='/tmp/', callback=None): + self.id = uuid.uuid4() self.inventory = inventory self.playbook = playbook @@ -96,7 +97,16 @@ class PlaybookRunner: self.cb = callback 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): + self.copy_playbook() + verbosity = get_ansible_log_verbosity(verbosity) private_env = safe_join(self.project_dir, 'env') if os.path.exists(private_env): diff --git a/apps/ops/models/job.py b/apps/ops/models/job.py index 2b38592f8..6181ed1f0 100644 --- a/apps/ops/models/job.py +++ b/apps/ops/models/job.py @@ -339,7 +339,9 @@ class JobExecution(JMSOrgBaseModel): ) elif self.current_job.type == Types.playbook: 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: job_id = self.current_job.id @@ -522,7 +524,6 @@ class JobExecution(JMSOrgBaseModel): ssh_tunnel.local_gateway_clean(runner) def stop(self): - unit_id_path = os.path.join(self.private_dir, "local.unitid") if os.path.exists(unit_id_path): with open(unit_id_path) as f: diff --git a/jms b/jms index ff96723b7..0b2cf94d0 100755 --- a/jms +++ b/jms @@ -188,7 +188,7 @@ if __name__ == '__main__': ) parser.add_argument( "services", type=str, default='all', nargs="*", - choices=("all", "web", "task", "receptor"), + choices=("all", "web", "task"), help="The service to start", ) parser.add_argument('-d', '--daemon', nargs="?", const=True)