networking - Ansible Networks 错误“操作需要提权”
问题描述
我正在关注 youtube 上的基本 Ansible 网络工程师演示,并收到以下错误:
ubuntu@DESKTOP-P91I0V3:~/Ansible/Networking$ ansible-playbook ansible-router\ play2.yml -v 使用 /etc/ansible/ansible.cfg 作为配置文件
播放 [Danny 的通用路由器配置] ******************************************* ****************************************************** **
任务 [全局配置设置] ************************************************ ****************************************************** ****************** 致命:[R1]:失败!=> {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "操作需要提权"}
播放回顾 ************************************************ ****************************************************** ****************************** R1 : 正常=0 已更改=0 无法访问=0 失败=1 已跳过=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”和没有“host_key_checking”我在 Stack Overflow 中看到其他人有类似的问题,但没有任何东西可以明确解决我的问题。
我可以从我的 WSL2 Ubuntu 环境 SSH 到 R1。
谁能帮我解决这个“操作需要提权”的问题吗?
解决方案
知道了!很多人建议“成为”方法在我的情况下不起作用。对我来说,修复只是两行,可以在 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:思科
授权:是
我希望这对将来的其他人有所帮助。
推荐阅读
- flutter - Flutter 失去与物理设备的连接
- kubernetes - 如何在 kubernetes 的第二个和第三个 pod 上执行命令
- python - 从大型 CSV 文件中删除最后一列
- ansible - 在特定主机上执行 ansible 任务
- c# - 反序列化具有可变 ID 的 Json 字符串
- c# - Dart 中的 switch case 和 if elseif 之间是否存在性能差异
- entity-framework-core - 如何将“FromSql()”查询的结果建模为基本数据类型?
- laravel - Laravel分页不刷新页面
- edit - 如何修改 Mifare 1K 标签的块 0 / UID(使用 proxmark)
- android - 使用 next() 和 previous() 遍历列表