From b15c31438442695c19e8b87e9cbf52914e93a9fd Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:59:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B5=84=E4=BA=A7=E5=A4=9A=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E6=97=B6=20=E8=AE=A1=E7=AE=97=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E9=94=99=E8=AF=AF=20(#12120)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- .../accounts/automations/change_secret/custom/ssh/main.yml | 7 ++++--- .../automations/verify_account/custom/ssh/main.yml | 3 ++- apps/assets/automations/ping/custom/ssh/main.yml | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/accounts/automations/change_secret/custom/ssh/main.yml b/apps/accounts/automations/change_secret/custom/ssh/main.yml index 7e30bf62b..25d26e549 100644 --- a/apps/accounts/automations/change_secret/custom/ssh/main.yml +++ b/apps/accounts/automations/change_secret/custom/ssh/main.yml @@ -3,12 +3,13 @@ vars: ansible_connection: local ansible_become: false + asset_port: "{{ jms_asset.protocols | selectattr('name', 'equalto', 'ssh') | map(attribute='port') | first }}" tasks: - name: Test privileged account (paramiko) ssh_ping: login_host: "{{ jms_asset.address }}" - login_port: "{{ jms_asset.port }}" + login_port: "{{ asset_port }}" login_user: "{{ jms_account.username }}" login_password: "{{ jms_account.secret }}" login_secret_type: "{{ jms_account.secret_type }}" @@ -25,7 +26,7 @@ login_user: "{{ jms_account.username }}" login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" - login_port: "{{ jms_asset.port }}" + login_port: "{{ asset_port }}" login_secret_type: "{{ jms_account.secret_type }}" login_private_key_path: "{{ jms_account.private_key_path }}" become: "{{ custom_become | default(False) }}" @@ -46,7 +47,7 @@ login_user: "{{ account.username }}" login_password: "{{ account.secret }}" login_host: "{{ jms_asset.address }}" - login_port: "{{ jms_asset.port }}" + login_port: "{{ asset_port }}" become: "{{ account.become.ansible_become | default(False) }}" become_method: su become_user: "{{ account.become.ansible_user | default('') }}" diff --git a/apps/accounts/automations/verify_account/custom/ssh/main.yml b/apps/accounts/automations/verify_account/custom/ssh/main.yml index c565f6f83..4519fc3ad 100644 --- a/apps/accounts/automations/verify_account/custom/ssh/main.yml +++ b/apps/accounts/automations/verify_account/custom/ssh/main.yml @@ -2,13 +2,14 @@ gather_facts: no vars: ansible_connection: local + ansible_shell_type: sh ansible_become: false tasks: - name: Verify account (paramiko) ssh_ping: login_host: "{{ jms_asset.address }}" - login_port: "{{ jms_asset.port }}" + login_port: "{{ jms_asset.protocols | selectattr('name', 'equalto', 'ssh') | map(attribute='port') | first }}" login_user: "{{ account.username }}" login_password: "{{ account.secret }}" login_secret_type: "{{ account.secret_type }}" diff --git a/apps/assets/automations/ping/custom/ssh/main.yml b/apps/assets/automations/ping/custom/ssh/main.yml index 7820df8e7..925d3f2e1 100644 --- a/apps/assets/automations/ping/custom/ssh/main.yml +++ b/apps/assets/automations/ping/custom/ssh/main.yml @@ -2,6 +2,7 @@ gather_facts: no vars: ansible_connection: local + ansible_shell_type: sh ansible_become: false tasks: @@ -10,7 +11,7 @@ login_user: "{{ jms_account.username }}" login_password: "{{ jms_account.secret }}" login_host: "{{ jms_asset.address }}" - login_port: "{{ jms_asset.port }}" + login_port: "{{ jms_asset.protocols | selectattr('name', 'equalto', 'ssh') | map(attribute='port') | first }}" login_secret_type: "{{ jms_account.secret_type }}" login_private_key_path: "{{ jms_account.private_key_path }}" become: "{{ custom_become | default(False) }}"