From 11b244888d2ebcd4553984fdb98e02f5c1ae6de0 Mon Sep 17 00:00:00 2001 From: lettimepassby <86416409@qq.com> Date: Wed, 29 Apr 2026 15:37:36 +0800 Subject: [PATCH] fix: failure when changing network device passwords through a gateway --- apps/accounts/automations/change_secret/custom/ssh/main.yml | 2 ++ apps/libs/ansible/modules_utils/custom_common.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/accounts/automations/change_secret/custom/ssh/main.yml b/apps/accounts/automations/change_secret/custom/ssh/main.yml index 54707a7d5..464a83106 100644 --- a/apps/accounts/automations/change_secret/custom/ssh/main.yml +++ b/apps/accounts/automations/change_secret/custom/ssh/main.yml @@ -40,6 +40,8 @@ password: "{{ account.secret }}" commands: "{{ params.commands }}" first_conn_delay_time: "{{ first_conn_delay_time | default(0.5) }}" + gateway_args: "{{ jms_asset.ansible_ssh_common_args | default(None) }}" + old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}" ignore_errors: true when: ping_info is succeeded register: change_info diff --git a/apps/libs/ansible/modules_utils/custom_common.py b/apps/libs/ansible/modules_utils/custom_common.py index 08d7f93cf..052a18f72 100644 --- a/apps/libs/ansible/modules_utils/custom_common.py +++ b/apps/libs/ansible/modules_utils/custom_common.py @@ -174,7 +174,7 @@ class SSHClient: self.client.connect(**self.connect_params) self.is_connect = True err_msg = self.switch_user() - self.after_runner_end() + # self.after_runner_end() except Exception as err: err_msg = str(err) return err_msg @@ -205,6 +205,8 @@ class SSHClient: output += received_output except Exception as e: error_msg = str(e) + finally: + self.after_runner_end() return output, error_msg def __del__(self):