diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index 9c0d03849..653c5f40d 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -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): diff --git a/apps/ops/models/job.py b/apps/ops/models/job.py index 06a858bd6..3cd63e293 100644 --- a/apps/ops/models/job.py +++ b/apps/ops/models/job.py @@ -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()