mirror of https://github.com/jumpserver/jumpserver
perf: Ansible inventory set jms
parent
887724bad4
commit
9be77cf58f
|
@ -13,11 +13,11 @@
|
|||
login_password: "{{ jms_account.secret }}"
|
||||
login_secret_type: "{{ jms_account.secret_type }}"
|
||||
login_private_key_path: "{{ jms_account.private_key_path }}"
|
||||
become: "{{ custom_become | default(False) }}"
|
||||
become_method: "{{ custom_become_method | default('su') }}"
|
||||
become_user: "{{ custom_become_user | default('') }}"
|
||||
become_password: "{{ custom_become_password | default('') }}"
|
||||
become_private_key_path: "{{ custom_become_private_key_path | default(None) }}"
|
||||
become: "{{ jms_custom_become | default(False) }}"
|
||||
become_method: "{{ jms_custom_become_method | default('su') }}"
|
||||
become_user: "{{ jms_custom_become_user | default('') }}"
|
||||
become_password: "{{ jms_custom_become_password | default('') }}"
|
||||
become_private_key_path: "{{ jms_custom_become_private_key_path | default(None) }}"
|
||||
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
|
||||
gateway_args: "{{ jms_asset.ansible_ssh_common_args | default(None) }}"
|
||||
register: ping_info
|
||||
|
@ -31,11 +31,11 @@
|
|||
login_port: "{{ jms_asset.port }}"
|
||||
login_secret_type: "{{ jms_account.secret_type }}"
|
||||
login_private_key_path: "{{ jms_account.private_key_path }}"
|
||||
become: "{{ custom_become | default(False) }}"
|
||||
become_method: "{{ custom_become_method | default('su') }}"
|
||||
become_user: "{{ custom_become_user | default('') }}"
|
||||
become_password: "{{ custom_become_password | default('') }}"
|
||||
become_private_key_path: "{{ custom_become_private_key_path | default(None) }}"
|
||||
become: "{{ jms_custom_become | default(False) }}"
|
||||
become_method: "{{ jms_custom_become_method | default('su') }}"
|
||||
become_user: "{{ jms_custom_become_user | default('') }}"
|
||||
become_password: "{{ jms_custom_become_password | default('') }}"
|
||||
become_private_key_path: "{{ jms_custom_become_private_key_path | default(None) }}"
|
||||
name: "{{ account.username }}"
|
||||
password: "{{ account.secret }}"
|
||||
commands: "{{ params.commands }}"
|
||||
|
|
|
@ -37,7 +37,7 @@ class SSHTunnelManager:
|
|||
info = self.file_to_json(runner.inventory)
|
||||
servers, not_valid = [], []
|
||||
for k, host in info['all']['hosts'].items():
|
||||
jms_asset, jms_gateway = host.get('jms_asset'), host.get('gateway')
|
||||
jms_asset, jms_gateway = host.get('jms_asset'), host.get('jms_gateway')
|
||||
if not jms_gateway:
|
||||
continue
|
||||
try:
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
login_port: "{{ jms_asset.port }}"
|
||||
login_secret_type: "{{ jms_account.secret_type }}"
|
||||
login_private_key_path: "{{ jms_account.private_key_path }}"
|
||||
become: "{{ custom_become | default(False) }}"
|
||||
become_method: "{{ custom_become_method | default('su') }}"
|
||||
become_user: "{{ custom_become_user | default('') }}"
|
||||
become_password: "{{ custom_become_password | default('') }}"
|
||||
become_private_key_path: "{{ custom_become_private_key_path | default(None) }}"
|
||||
become: "{{ jms_custom_become | default(False) }}"
|
||||
become_method: "{{ jms_custom_become_method | default('su') }}"
|
||||
become_user: "{{ jms_custom_become_user | default('') }}"
|
||||
become_password: "{{ jms_custom_become_password | default('') }}"
|
||||
become_private_key_path: "{{ jms_custom_become_private_key_path | default(None) }}"
|
||||
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
|
||||
gateway_args: "{{ jms_asset.ansible_ssh_common_args | default(None) }}"
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import re
|
|||
from collections import defaultdict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
from assets.const.category import Category
|
||||
|
||||
__all__ = ['JMSInventory']
|
||||
|
||||
|
@ -84,11 +83,11 @@ class JMSInventory:
|
|||
def make_custom_become_ansible_vars(account, su_from_auth, path_dir):
|
||||
su_method = su_from_auth['ansible_become_method']
|
||||
var = {
|
||||
'custom_become': True,
|
||||
'custom_become_method': su_method,
|
||||
'custom_become_user': account.su_from.username,
|
||||
'custom_become_password': account.escape_jinja2_syntax(account.su_from.secret),
|
||||
'custom_become_private_key_path': account.su_from.get_private_key_path(path_dir)
|
||||
'jms_custom_become': True,
|
||||
'jms_custom_become_method': su_method,
|
||||
'jms_custom_become_user': account.su_from.username,
|
||||
'jms_custom_become_password': account.escape_jinja2_syntax(account.su_from.secret),
|
||||
'jms_custom_become_private_key_path': account.su_from.get_private_key_path(path_dir)
|
||||
}
|
||||
return var
|
||||
|
||||
|
@ -132,7 +131,7 @@ class JMSInventory:
|
|||
if gateway:
|
||||
ansible_connection = host.get('ansible_connection', 'ssh')
|
||||
if ansible_connection in ('local', 'winrm', 'rdp'):
|
||||
host['gateway'] = {
|
||||
host['jms_gateway'] = {
|
||||
'address': gateway.address, 'port': gateway.port,
|
||||
'username': gateway.username, 'secret': gateway.password,
|
||||
'private_key_path': gateway.get_private_key_path(path_dir)
|
||||
|
|
Loading…
Reference in New Issue