如何解决Ansible Juniper.Device 集合:“JuniperJunosModule”对象没有属性“conn_type”
我对这个问题非常头疼,不知道如何处理。我有一个简单的剧本,我尝试将固件和新配置上传到瞻博网络交换机。
---
- name: Juniper Playbook
hosts: junos
gather_facts: no
collections:
- juniper.device
vars:
username: foo
password: foo
conf: "foo.cfg"
firmware : "foo.tgz"
tasks:
- name: Checking NETCONF connectivity (Timeout 5 minutes)
wait_for:
host: "{{ inventory_hostname }}"
port: 830
timeout: 300
- name: Installing Junos OS package
juniper.device.software:
reboot: yes
local_package: "{{ firmware }}"
user: "{{ user }}"
password: "{{ password }}"
register: sw
- name: Wait for reboot if OS changed
wait_for:
host: "{{ inventory_hostname }}"
port: 830
timeout: 300
#when: sw.changed
- name: Installing configuration
juniper.device.config:
src: "{{ conf }}"
update: "override"
那么,一切都应该没问题了,我已经安装了 juniper.device 集合
Maxime$ ansible-galaxy collection list
# /XXX/XXX/.ansible/collections/ansible_collections
Collection Version
----------------- -------
ansible.netcommon 2.1.0
ansible.utils 2.2.0
juniper.device 1.0.0
我从 virtualenv 运行剧本(我知道这些信息没有什么意义,但在这里是 ^^)
(pfe_env) Maxime$ python -m pip freeze
altgraph==0.17
ansible==4.1.0
ansible-base==2.10.10
ansible-core==2.11.1
ansible-runner==1.4.7
bcrypt==3.2.0
cffi==1.14.5
cryptography==3.4.7
docutils==0.17.1
future==0.18.2
ipaddr==2.2.0
Jinja2==3.0.1
junos-eznc==2.6.1
jxmlease==1.0.3
lockfile==0.12.2
lxml==4.6.3
macholib==1.14
MarkupSafe==2.0.1
modulegraph==0.18
ncclient==0.6.12
netaddr==0.8.0
packaging==20.9
paramiko==2.7.2
pexpect==4.8.0
psutil==5.8.0
ptyprocess==0.7.0
py2app==0.24
pycparser==2.20
pyhpecw7==0.0.11
pyinstaller-hooks-contrib==2021.1
pynacl==1.4.0
pyparsing==2.4.7
pyserial==3.5
pyside2==5.15.2
python-daemon==2.3.0
PyYAML==5.4.1
resolvelib==0.5.4
scp==0.13.3
shiboken2==5.15.2
six==1.15.0
textfsm==1.1.0
toml==0.10.2
transitions==0.8.8
xmltodict==0.12.0
yamlordereddictloader==0.4.0
好吧,当我执行这个剧本时,我不断收到 AttributeError: 'JuniperJunosModule' object has no attribute 'conn_type'
查看 Juniper documentation 应该是因为我正在使用我没有使用的提供程序。因此,要么我的剧本中存在另一个错误,该错误未生成适当的错误消息要么 juniper.device 集合有问题?公平地说,我认为第一个断言更有可能是真的。
好吧,如果您对此有任何提示,我会很高兴收到您的想法和想法!我在瞻博网络 EX4300 上运行这本剧本的另一个精度,我的 Python 版本是 Python 3.8.6
这里快速浏览一下我的库存
[junos]
1.1.1.1 #obvIoUsly fake address for online posting
[junos:vars]
ansible_connection=ansible.netcommon.netconf
ansible_user=foo
ansible_password=foo
ansible_python_interpreter="/XXX/XXX/pfe_env/bin/python"
谢谢!
解决方法
您正在使用
ansible_connection=ansible.netcommon.netconf
juniper.device 集合不支持它。您应该使用 ansible_connection=local
或 ansible_connection=juniper.device.pyez
。
建议您在代码库的 github 存储库中提出有关 juniper.device 集合的任何问题,以便更快地解决 juniper.device .
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。