【问题标题】:How to run Privilege Exec command in Ansible on Cisco Router如何在 Cisco 路由器上的 Ansible 中运行 Privilege Exec 命令
【发布时间】:2018-10-29 19:49:56
【问题描述】:

我正在尝试编写一个剧本来执行数据包捕获。命令以特权执行模式运行,即#Not config mode (config#) and not user exec (>)

我必须运行 become 和 become_method: enable 才能进入设备。但是,当我使用 become 和 become_method 运行剧本时,我得到 \r\n% Invalid input detected at '^' marker.\r\n\r\nrouter(config)#\n"。

当我在没有 become 和 become_method 的情况下运行 playbook 时,我得到“操作需要提权\n”

有问题的命令:

  - name: setup packet capture
    ios_config:
      lines:
        - monitor capture buffer PKT size 2048 max-size 4096 circular
        - monitor capture buffer PKT filter access-list PackCap
    become: yes
    become_method: enable

如何在仅特权执行模式下运行命令?

谢谢!

【问题讨论】:

  • 你确定你不想要ios_command,因为我可以告诉你monitor capture 不是一个config 设置
  • 是的,ios_command 的错误是:FAILED! => {"changed": false, "msg": "(ios_command) 模块不支持的参数:lines 支持的参数包括:auth_pass、authorize、commands、host、interval、match、password、port、provider、retries、ssh_keyfile、timeout , 用户名, wait_for"}
  • 我相信文档说使用 commands: 而不是 lines:
  • @MatthewLDaniel 您的评论是解决方案,谢谢!我曾认为“行”和“命令”是可以互换的。

标签: ansible


【解决方案1】:

您会想要使用ios_command,因为monitor capture 不是配置设置

还要小心使用commands: 而不是lines:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-25
    • 1970-01-01
    • 2019-02-18
    • 2018-06-22
    • 1970-01-01
    相关资源
    最近更新 更多