ansible - 如何为 Cisco 交换机提供端口安全性
问题描述
我在 Ansible 中执行剧本时遇到问题
---
- hosts: cisco
gather_facts: true
vars:
ansible_become: yes
ansible_become_method: enable
ansible_user: cisco
ansible_password: cisco
ansible_become_pass: cisco
ansible_network_os: ios
ansible_connection: network_cli
tasks:
- name: port security
ios_config:
lines:
- interface fastEthernet0/4
- switchport mode access
- switchport port security
- switchport security maximum 1
- switchport port security mac-address sticky
- switchport port security voilation shutdown
完整的追溯是:
警告:以下回溯可能与实际故障无关。文件“/tmp/ansible_ios_command_payload_6a9kGj/ansible_ios_command_payload.zip/ansible/module_utils/network/ios/ios.py”,第 145 行,在 run_commands 返回 connection.run_commands(commands=commands, check_rc=check_rc) 文件“/tmp/ansible_ios_command_payload_6a9kGj/ansible_ios_command_payload .zip/ansible/module_utils/connection.py",第 182 行,在 rpc 中引发 ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
致命:[cisco]:失败!=> {“更改”:false,“调用”:{“module_args”:{“auth_pass”:null,“授权”:null,“命令”:[“接口fastEthernet0/24”,“switchport模式访问”,“ switchport port security”, “switchport security maximum 1”, “switchport port security mac-address sticky”, “switchport port security voilation shutdown”], “host”: null, “interval”: 1, “match”: “all” ,“密码”:空,“端口”:空,“提供者”:空,“重试”:10,“ssh_keyfile”:空,“超时”:空,“用户名”:空,“wait_for”:空 } } ,“味精”:“
播放回顾 ************************************************ ****************************************************** ****************************************************** ********* 思科:正常=0 更改=0 无法访问=0 失败=1**
解决方案
推荐阅读
- php - Wordpress – 按元值按字母顺序对帖子进行排序
- bamboo - Bamboo 不会在计划中自动创建分支
- java - 如何在 JScrollPanel 中添加 JPanel,然后再次添加 JPanel?
- javascript - 提交错误的表单时网页刷新到顶部
- android - 使用 angular 与 angular-nativescript 组件有什么区别
- ruby-on-rails - 如何存储加密数据?
- java - 有没有办法在不区分大小写的情况下比较 2 个字符串?
- axios - 可以使用 node-fetch 向 localhost 发出 post 请求,但无法使用 Axios 这样做
- php - 调用未定义的方法“Illuminate\\Database\\Query\\Builder::can()”
- http - Nativescript HTTP 模块安全吗?