我的Cisco路由器有问题。我无法打开配置终端,因为它总是说输入无效。医生说的我都做了。库存文件:
all:
vars:
ansible_connection: network_cli
ansible_network_os: ios
ansible_user: user
ansible_ssh_pass: pass
ansible_become: yes
ansible_become_method: enable
ansible_become_password: pass
ansible_python_interpreter: python
accept_hostkey: yes
ansible_host_key_checking: false
hosts:
testcisco:
ansible_host: ip
行动手册:
---
- hosts: all
ignore_errors: yes
gather_facts: no
tasks:
- name: Config
cisco.ios.ios_command:
commands: "configure terminal"
register: output
- debug:
msg: "{{ output }}"
输出:
fatal: [testcisco]: FAILED! => {"changed": false, "msg": "configure terminalrnconfigure terminalrn ^rn% Invalid input detected at '^' marker.rnrn------#"}
无论我键入什么配置终端、conft等。它总是说输入无效
由于某种原因,Ansible决定运行conf t的两个实例,这很奇怪。然而,您不需要在Ansible中进入全局配置模式,请参阅以下文档:https://docs.ansible.com/ansible/latest/collections/cisco/ios/ios_config_module.html
特别是这部分
- name: configure top level configuration
cisco.ios.ios_config:
lines: hostname {{ inventory_hostname }}
- name: configure interface settings
cisco.ios.ios_config:
lines:
- description test interface
- ip address 172.31.1.1 255.255.255.0
parents: interface Ethernet1
您可以看到,您可以在剧本本身中完成所需的大多数/所有配置更改。
您也可以只键入ios_config并省略单词cisco