Ansible 上传本地配置到服务器错误 ansible_network_os must be specified on this host

错误信息如下:

TASK [copy file at root dir of flash in slot 3 of sw1(ios)] *****************************************************************************************************************************************************************************************************************************************************************
fatal: [54.39.157.60]: FAILED! => {"msg": "ansible_network_os must be specified on this host"}

问题和解决

这个问题的主要原因我们使用了:

ansible.netcommon.net_put:

这个组件需要设置 ansible_network_os 配置。

可选的办法是使用 ansible.builtin.copy: 组件来进行替换。

完成上面的修改后,再次运行就能够将文件顺利上传了。