aabouzaid / netbox-as-ansible-inventory

Ansible dynamic inventory script for Netbox.
GNU General Public License v3.0
174 stars 54 forks source link

AttributeError when generating inventory #3

Closed jpatmore closed 7 years ago

jpatmore commented 7 years ago

Hi

I'm running in to the following error when I try and run the inventory;

$ sudo python netbox.py --list

Traceback (most recent call last): File "netbox.py", line 344, in main() File "netbox.py", line 339, in main ansible_inventory = netbox.generate_inventory() File "netbox.py", line 306, in generate_inventory server_name = current_host.get("name") AttributeError: 'unicode' object has no attribute 'get'

...have been trying to troubleshoot it, but just cant get to the bottom of the cause - would appreciate any steer as very interested in using your code for our production Netbox deployment

aabouzaid commented 7 years ago

Hi @jpatmore Could you add more details please?

versions of system, python, netbox, and json output example.

jpatmore commented 7 years ago

Sure - very much appreciate the quick response :)

OS : Red Hat Enterprise Linux Server release 7.3 (Maipo) Ansible : 2.2.1.0 Python : 2.7.5 Netbox : v1.9.6 (running on separate Ubuntu system), with Docker install method

Can't get any JSON output unfortunately, as i receive the above error when I try and run anything.

Any other info/output that would help, let me know - curious as to whether its any unique settings we have in our Netbox deployment that could be causing the issue

bdlamprecht commented 7 years ago

@AAbouZaid

I'm also encountering this same issue when running the script in the following environment:

OS : Ubuntu 16.04.2 LTS Ansible : 2.3.0.0 Python : 2.7.12 Netbox : 2.0.2 (also on separate system)

I'm really interested in getting this to work and appreciate any help you can provide.

aabouzaid commented 7 years ago

There is a change happened that broke the script. I did a quick fix with commit 5948b5309e3bb3c8b1da2c3961212dfea6afc46f to make sure it will work with older versions too.

Please pull devel branch, test it, and if it works fine, I will push it to master.

Thanks for reporting this issue :-)

bdlamprecht commented 7 years ago

Yeah, that seemed to fix it. I can now get a list of all of the devices in my installation of netbox. Now I need to figure out how to implement it correctly with Ansible.

Thanks again.

aabouzaid commented 7 years ago

Great, thanks again :-)