mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-08-09 16:11:22 +00:00
perf: merge Cisco change secret into dev
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
become_private_key_path: "{{ jms_custom_become_private_key_path | default(None) }}"
|
||||
name: "{{ account.username }}"
|
||||
password: "{{ account.secret }}"
|
||||
privilege_password: "{{ account.become.ansible_become_password | default(jms_account.secret) }}"
|
||||
commands: "{{ params.commands }}"
|
||||
answers: "{{ params.answers }}"
|
||||
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
|
||||
|
||||
@@ -47,38 +47,44 @@ i18n:
|
||||
1. 改密账号 -> {username} <br />
|
||||
2. 改密密码 -> {password} <br />
|
||||
3. 登录用户密码 -> {login_password} <br />
|
||||
4. 已有特权密码(如 Cisco enable 密码) -> {privilege_password} <br />
|
||||
<strong>多条命令使用换行分割,</strong>执行任务时系统会根据特殊符号替换真实数据。<br />
|
||||
比如针对 Cisco 主机进行改密,一般需要配置五条命令:<br />
|
||||
比如针对 Cisco enable 权限进行改密,一般需要配置以下命令:<br />
|
||||
enable <br />
|
||||
{login_password} <br />
|
||||
{privilege_password} <br />
|
||||
configure terminal <br />
|
||||
username {username} privilege 0 password {password} <br />
|
||||
enable secret {password} <br />
|
||||
end <br />
|
||||
write memory <br />
|
||||
ja: |
|
||||
コマンド内の指定された位置を特殊記号に変更してください。<br />
|
||||
新しいパスワード(アカウント変更) -> {username} <br />
|
||||
新しいパスワード(パスワード変更) -> {password} <br />
|
||||
ログインユーザーパスワード -> {login_password} <br />
|
||||
既存の特権パスワード(Cisco enable パスワードなど) -> {privilege_password} <br />
|
||||
<strong>複数のコマンドは改行で区切り、</strong>タスクを実行するときにシステムは特殊記号を使用して実際のデータを置き換えます。<br />
|
||||
例えば、Cisco機器のパスワードを変更する場合、一般的には5つのコマンドを設定する必要があります:<br />
|
||||
例えば、Cisco の enable パスワードを変更する場合、次のコマンドを設定します:<br />
|
||||
enable <br />
|
||||
{login_password} <br />
|
||||
{privilege_password} <br />
|
||||
configure terminal <br />
|
||||
username {username} privilege 0 password {password} <br />
|
||||
enable secret {password} <br />
|
||||
end <br />
|
||||
write memory <br />
|
||||
en: |
|
||||
Please change the specified positions in the command to special symbols. <br />
|
||||
Change password account -> {username} <br />
|
||||
Change password -> {password} <br />
|
||||
Login user password -> {login_password} <br />
|
||||
Existing privilege password (such as a Cisco enable password) -> {privilege_password} <br />
|
||||
<strong>Multiple commands are separated by new lines,</strong> and when executing tasks, <br />
|
||||
the system will replace the special symbols with real data. <br />
|
||||
For example, to change the password for a Cisco device, you generally need to configure five commands: <br />
|
||||
For example, to change a Cisco enable password, configure the following commands: <br />
|
||||
enable <br />
|
||||
{login_password} <br />
|
||||
{privilege_password} <br />
|
||||
configure terminal <br />
|
||||
username {username} privilege 0 password {password} <br />
|
||||
enable secret {password} <br />
|
||||
end <br />
|
||||
write memory <br />
|
||||
|
||||
Params commands label:
|
||||
zh: '自定义命令'
|
||||
|
||||
@@ -30,6 +30,10 @@ options:
|
||||
- The password to use for the user.
|
||||
type: str
|
||||
aliases: [pass]
|
||||
privilege_password:
|
||||
description:
|
||||
- The existing privilege or enable password used by custom commands.
|
||||
type: str
|
||||
commands:
|
||||
description:
|
||||
- Custom change password commands.
|
||||
@@ -71,11 +75,13 @@ def get_commands_and_answers(module) -> (list, list):
|
||||
commands = module.params['commands'] or ''
|
||||
answers = module.params['answers'] or ''
|
||||
login_password = module.params['login_password']
|
||||
privilege_password = module.params.get('privilege_password', '')
|
||||
|
||||
for field_name, value in (
|
||||
('username', username),
|
||||
('password', password),
|
||||
('login_password', login_password),
|
||||
('privilege_password', privilege_password),
|
||||
):
|
||||
if value and ('\r' in value or '\n' in value):
|
||||
module.fail_json(
|
||||
@@ -91,9 +97,10 @@ def get_commands_and_answers(module) -> (list, list):
|
||||
'username': username,
|
||||
'password': password,
|
||||
'login_password': login_password,
|
||||
'privilege_password': privilege_password,
|
||||
}
|
||||
commands = re.sub(
|
||||
r'\{(username|password|login_password)\}',
|
||||
r'\{(username|password|login_password|privilege_password)\}',
|
||||
lambda match: replacements.get(match.group(1)) or '',
|
||||
commands,
|
||||
)
|
||||
@@ -112,6 +119,7 @@ def main():
|
||||
argument_spec.update(
|
||||
name=dict(required=True, aliases=['user']),
|
||||
password=dict(aliases=['pass'], no_log=True),
|
||||
privilege_password=dict(default='', no_log=True),
|
||||
)
|
||||
module = AnsibleModule(argument_spec=argument_spec)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user