From 2ba32f6971eaa07fd1cb64811d716575163a0428 Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Wed, 19 Apr 2023 14:44:06 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=94=B9=E5=AF=86=E6=97=B6=E9=9C=80=E8=A6=81=E5=9C=A8?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E4=B8=AD=E5=8C=85=E5=90=ABssh=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=94=A8=E6=88=B7=E7=9A=84=E5=AF=86=E7=A0=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accounts/automations/change_secret/custom/ssh/manifest.yml | 2 +- apps/ops/ansible/modules/custom_command.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/accounts/automations/change_secret/custom/ssh/manifest.yml b/apps/accounts/automations/change_secret/custom/ssh/manifest.yml index 2796c32c4..465cfa1e2 100644 --- a/apps/accounts/automations/change_secret/custom/ssh/manifest.yml +++ b/apps/accounts/automations/change_secret/custom/ssh/manifest.yml @@ -11,4 +11,4 @@ params: type: list label: '自定义命令' default: [''] - help_text: '自定义命令中如需包含账号的 username 和 password 字段,请使用 {username}、{password}格式,执行任务时会进行替换 。
比如针对 Linux 主机进行改密,一般需要配置三条命令:
1.passwd {username}
2.{password}
3.{password}' + help_text: '自定义命令中如需包含账号的 账号、密码、SSH 连接的用户密码 字段,
请使用 {username}、{password}、{login_password}格式,执行任务时会进行替换 。
比如针对 Cisco 主机进行改密,一般需要配置五条命令:
1. enable
2. {login_password}
3. configure terminal
4. username {username} privilege 0 password {password}
5. end' diff --git a/apps/ops/ansible/modules/custom_command.py b/apps/ops/ansible/modules/custom_command.py index 4205e7088..4edff4324 100644 --- a/apps/ops/ansible/modules/custom_command.py +++ b/apps/ops/ansible/modules/custom_command.py @@ -72,9 +72,10 @@ def get_commands(module): username = module.params['name'] password = module.params['password'] commands = module.params['commands'] or [] + login_password = module.params['login_password'] for index, command in enumerate(commands): commands[index] = command.format( - username=username, password=password + username=username, password=password, login_password=login_password ) return commands