首页 > 解决方案 > 如何为 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**

标签: ansible

解决方案


推荐阅读