diff --git a/apps/accounts/automations/change_secret/custom/ssh/main.yml b/apps/accounts/automations/change_secret/custom/ssh/main.yml index 42201392b..54707a7d5 100644 --- a/apps/accounts/automations/change_secret/custom/ssh/main.yml +++ b/apps/accounts/automations/change_secret/custom/ssh/main.yml @@ -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 }}" diff --git a/apps/assets/automations/base/manager.py b/apps/assets/automations/base/manager.py index 909ca5638..740980040 100644 --- a/apps/assets/automations/base/manager.py +++ b/apps/assets/automations/base/manager.py @@ -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: diff --git a/apps/assets/automations/ping/custom/ssh/main.yml b/apps/assets/automations/ping/custom/ssh/main.yml index d40a7a4e8..89b92bcaa 100644 --- a/apps/assets/automations/ping/custom/ssh/main.yml +++ b/apps/assets/automations/ping/custom/ssh/main.yml @@ -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) }}" diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index b9a559c08..fde3f290b 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -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)