mirror of https://github.com/jumpserver/jumpserver
perf: 修改 inventory
parent
8f59e49099
commit
e015dd7bcb
|
@ -270,8 +270,13 @@ class JMSInventory:
|
|||
name = host.pop('name')
|
||||
name = name.replace('[', '_').replace(']', '_')
|
||||
data['all']['hosts'][name] = host
|
||||
if self.exclude_localhost and data['all']['hosts'].__contains__('localhost'):
|
||||
data['all']['hosts'].update({'localhost': {'ansible_host': '255.255.255.255'}})
|
||||
if not self.exclude_localhost:
|
||||
data['all']['hosts'].update({
|
||||
'localhost': {
|
||||
'ansible_host': '127.0.0.1',
|
||||
'ansible_connection': 'local'
|
||||
}
|
||||
})
|
||||
return data
|
||||
|
||||
def write_to_file(self, path):
|
||||
|
|
|
@ -43,8 +43,8 @@ def get_parent_keys(key, include_self=True):
|
|||
|
||||
class JMSPermedInventory(JMSInventory):
|
||||
def __init__(self, assets, account_policy='privileged_first',
|
||||
account_prefer='root,Administrator', host_callback=None, exclude_localhost=False, user=None):
|
||||
super().__init__(assets, account_policy, account_prefer, host_callback, exclude_localhost)
|
||||
account_prefer='root,Administrator', host_callback=None, user=None):
|
||||
super().__init__(assets, account_policy, account_prefer, host_callback, exclude_localhost=True)
|
||||
self.user = user
|
||||
self.assets_accounts_mapper = self.get_assets_accounts_mapper()
|
||||
|
||||
|
|
Loading…
Reference in New Issue