0

I have a huge headache on this issue and can't figure out how to deal with it. I have a simple playbook where I try to upload a firmware and new conf to a Juniper switch.

---
- 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"

Well, everything should be ok then, I have the juniper.device collection installed

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 

I run playbooks from a virtualenv (I know this information is not really meaningful but here it is ^^)

(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

Well and when I execute this playbook, I keep getting a AttributeError: 'JuniperJunosModule' object has no attribute 'conn_type'

Looking at Juniper documentation it should be because I'm using a provider which I'm not. So either there's another error on my playbook that doesn't generated the appropriate error message either the juniper.device collection is buggy ? To be fair, I think the first assertion is more likely to be true.

Well, if you have any hint on this I'll be glad to have your thoughts and ideas ! One more precision I'm running this playbook on Juniper EX4300 and my Python version is Python 3.8.6

Here a quick look at my inventory

[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"

Thanks !

a-maxime
  • 35
  • 3

1 Answers1

1

You are using ansible_connection=ansible.netcommon.netconf which is not supported by juniper.device collection. You should use ansible_connection=local or ansible_connection=juniper.device.pyez .

It is recommended that you raise any issue with juniper.device collection at the github repository of the codebase for faster resolution juniper.device .

rahul
  • 13
  • 3
  • Hi Rahul, thanks for your message, yes I wasn't using with the correct connection parameter because I've been trying some things to test. Unfortunately, even with ansible_connection=local, I get a 'conn_type' error. I've opened an issued on GitHub, let me know if everything is right documented on it -> https://github.com/Juniper/ansible-junos-stdlib/issues/560 – a-maxime Jun 18 '21 at 12:06