【问题标题】:Ansible Networks error "operation requires privilege escalation"Ansible Networks 错误“操作需要提权”
【发布时间】:2021-09-03 19:20:10
【问题描述】:

我正在关注 youtube 上的基本 Ansible 网络工程师演示,但收到以下错误:


ubuntu@DESKTOP-P91I0V3:~/Ansible/Networking$ ansible-playbook ansible-router\ play2.yml -v 使用 /etc/ansible/ansible.cfg 作为配置文件

播放 [Danny 的通用路由器配置] **************************************** ****************************************************** *****

TASK [全局配置设置] ***************************************** ****************************************************** ****************** 致命:[R1]:失败! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "操作需要提权"}

播放回顾 ************************************************ ****************************************************** ************************************ R1 : ok=0 changed=0 unreachable=0 failed=1 skipped=0救出=0被忽略=0


我的剧本是这样的:


- name: Danny's Generic Router Configuration
  hosts: R1
  gather_facts: false
  connection: local

  vars:
    cli:
      username: admin
      password: cisco
      timeout: 100

  tasks:
    - name: Global config settings
      ios_config:

    provider: "{{ cli }}"
    lines:
      - ipv6 unicast-routing
      - errdisable recovery interval 60
      - security passwords min-length 5
      - ip name-server 99.99.99.99
      - no ip http server
      - ip http secure-server
      - snmp-server community ipvzero1 RO
      - snmp-server community ipvzero2 RW
      - ntp server 99.99.99.99
      - banner motd &**********THIS IS Danny'S ROUTER - DO NOT MAKE CHANGES UNLESS AUTHORISED! YOU WILL BE PROSECUTED! **********&

  register: print_output

-  debug: var=print_output

我的配置文件如下所示:


[defaults]
inventory = ./hosts
#host_key_checking = false
timeout = 60

我已经厌倦了使用和不使用“host_key_checking” 我在 Stack Overflow 中看到其他人也遇到过类似的问题,但没有任何东西可以彻底解决我的问题。

我可以从我的 WSL2 Ubuntu 环境通过 SSH 连接到 R1。

谁能帮我解决这个“操作需要提权”的问题吗?

【问题讨论】:

标签: networking automation ansible privileges cisco


【解决方案1】:

知道了! 很多人建议“成为”方法在我的情况下不起作用。 对我来说,修复只是两行,可以在 Ansible 文档中找到: https://docs.ansible.com/ansible/latest/collections/cisco/ios/ios_config_module.html


  vars:
    cli:
      username: admin
      password: cisco
      timeout: 100
      auth_pass: cisco

  tasks:
    - name: Global config settings
      ios_config:
        provider: "{{ cli }}"
        authorize: yes
        lines: 

有效的两行是:

auth_pass: 思科

授权:是的

我希望这对将来的其他人有所帮助。

【讨论】:

    猜你喜欢
    • 2018-09-20
    • 1970-01-01
    • 1970-01-01
    • 2013-04-29
    • 2022-12-04
    • 2021-08-25
    • 2015-06-02
    • 1970-01-01
    • 2021-07-19
    相关资源
    最近更新 更多