cisco-ios 的 Ansible 提示

问题描述 投票:0回答:1

我正在运行 ansible playbook,它传递一些 aaa 命令,一切都运行良好,直到我点击此命令:

aaa accounting identity default start-stop group ISE-RADIUS-SERVERS

当我直接在交换机上运行该命令时,会触发以下提示:

Net-Lab-02(config)#aaa accounting identity default start-stop group ISE-RADIUS-SERVERS
This operation will permanently convert all relevant authentication commands to their CPL control-policy equivalents. As this conversion is irreversible and will disable the conversion CLI 'authentication display [legacy|new-style]', you are strongly advised to back up your current configuration before proceeding. 
Do you wish to continue? [yes]:

这是我正在运行的剧本任务,我已经尝试了数百万种不同的变体,但似乎没有任何效果:

  tasks:
    - name: Run commands that require answering a prompt
      cisco.ios.ios_command:
        commands:
          - command: "aaa accounting identity default start-stop group ISE-RADIUS-SERVERS"
            prompt: 'Do you wish to continue? \[yes\]:'
            answer: "yes"

我收到以下错误:

fatal: [Net-Lab-02]: FAILED! => {"changed": false, "msg": "aaa accounting identity default start-stop group ISE-RADIUS-SERVERS\r\naaa accounting identity default start-stop group ISE-RADIUS-SERVERS\r\n ^\r\n% Invalid input detected at '^' marker.\r\n\r\nNet-Lab-02#"}
python ansible cisco
1个回答
0
投票

aaa accounting identity
config terminal
模式下的命令,
cisco.ios.ios_command
模块不支持在配置模式下运行命令。使用 ios_config 配置 IOS 设备。

但是,使用像

ios_config
这样的模块处理像“你想继续吗?[是]:”这样的交互式提示可能会很棘手,因为它没有内置的方法来响应此类提示。对于这种情况,可以使用
cli_command

- name: Run commands that require answering a prompt
  ansible.netcommon.cli_command:
    command: "{{ item }}"
    prompt:
      - Do you wish to continue
    answer: y
  loop:
    - configure
    - aaa accounting identity default start-stop group ISE-RADIUS-SERVERS
    - exit
© www.soinside.com 2019 - 2024. All rights reserved.