我现在的Ubuntu版本是20.10,Ansible 2.9.9的版本。
我在IOS 15.6上有带Cisco VIRL路由器的Eve NG
首先,我发现Ubuntu无法SSH到cisco路由器,因为没有找到匹配的密钥交换方法。他们的提议是:diffie-hellman-group1-sha1,我在使用~/.ssh/config时找到了一份工作。使用以下链接创建
~/.ssh/config 文件:
Host 192.168.100.2
KexAlgorithms=+diffie-hellman-group1-sha1
Host 192.168.100.3
KexAlgorithms=+diffie-hellman-group1-sha1_现在我正在尝试部署我的第一本剧本。
当我试图运行剧本时,我会得到以下错误:
fatal: [CSR-1]: FAILED! => {"changed": false, "msg": "Connection type ssh is not valid for this module"}
fatal: [CSR-2]: FAILED! => {"changed": false, "msg": "Connection type ssh is not valid for this module"}当我使用~/.ssh/config时,我可以从Ubuntu到每个路由器进行SSH,但是我不知道如何确定如何使用~/.ssh/config文件。
我尝试在ansible.cfg文件ssh_args = -F /home/a/.ssh/config中找到SSH文件的位置,但似乎无法让它工作。
我花了几个小时搜索谷歌,但找不到解决办法。
ansible.cfg
[defaults]
inventory =./host
host_key_checking = False
retry_files_enabled = False
gathering = explicit
Interpreter_python = /usr/bin/python3
ssh_args = -F /home/n/etc/ssh/ssh_config.d/*.confPlaybook
hosts: CSR_Routers
tasks:
name: Show Version
ios_command:
commands: show versionall.yml
ansible_user: "cisco"
ansible_ssh_pass: "cisco"
ansible_connection: "ssh"
ansible_network_os: "iso"
ansbile_connection: "network_cli"发布于 2021-01-17 14:32:29
SSH FIX -在Reddit中发布后
nano /etc/ssh/ssh_config
KexAlgorithms +diffie-hellman-group1-sha1
Ciphers +aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc
systemctl restart ssh
nano /etc/ansible/ansible.cfg
[defaults]
host_key_checking=False
timeout = 30带有细节的视频wuraYWuQ d02PiR1
发布于 2021-01-16 15:07:20
如果您看到文档,不要使用SSH作为连接类型,而是使用network_cli。所以-你不会通过默认ssh与设备对话,而是通过network_cli。将其作为主机特定的变量放入您的库存中。
all:
hosts:
CSR_01:
ansible_host: 192.168.100.2
ansible_connection: "network_cli"
ansible_network_os: "ios"
ansible_user: "cisco"
ansible_password: "cisco"
ansible_become: yes
ansible_become_method: enable
ansible_become_password: "cisco"
children:
CSR_Routers:
hosts:
CSR_01:根据您的操作手册,此目录包含一个组"CSR_Routers“,其上唯一的设备是IP 192.168.100.2的CSR_01。该设备的连接类型不是ssh而是network_cli。
所以你把你的剧本叫做:
ansible-playbook -i inventory.yaml playbook.yml还请看一下可抗中的IOS特定文档。
https://stackoverflow.com/questions/65748195
复制相似问题