Skip to content

Netbox | Could not resolve id of device_type #869

@asrivastav-aag

Description

@asrivastav-aag

Ansible NetBox Collection version

v3.8.1

Ansible version

ansible 2.10.4
  config file = /Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/scripts/ansible.cfg
  configured module search path = ['/Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/lib/python3.8/site-packages/napalm_ansible/modules']
  ansible python module location = /Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/lib/python3.8/site-packages/ansible
  executable location = /Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/bin/ansible
  python version = 3.8.6 (v3.8.6:db455296be, Sep 23 2020, 13:31:39) [Clang 6.0 (clang-600.0.57)]

NetBox version

2.3.0

Python version

3.8

Steps to Reproduce

  • name: Create devices
    netbox.netbox.netbox_device:
    netbox_url: "{{ netbox_url }}"
    netbox_token: "{{ netbox_token }}"
    data:
    name: "{{ item.name }}"
    status: active
    device_type:
    slug: "{{ item.device_type }}"
    device_role: "{{ item.device_role }}"
    platform: "{{ item.platform }}"
    rack: "{{ item.rack }}"
    position: "{{ item.position }}"
    face: front
    site: "{{ location.hq }}"
    loop:
    • name: R1
      device_type: ISR
      device_role: Router
      platform: ios
      rack: Row1RackA
      position: 1
    • name: S2
      device_type: ISR
      device_role: Switch
      platform: ios
      rack: Row1RackA
      position: 5
    • name: S3
      device_type: Nexus9000v
      device_role: Switch
      platform: nxos
      rack: Row1RackB
      position: 1
    • name: S4
      device_type: vMX
      device_role: Switch
      platform: junos
      rack: Row1RackB
      position: 5

Expected Behavior

I expect the same result as of S3 & S4 hosts - "changed".

===============================================
failed: [netbox1] (item={'name': 'R1', 'device_type': 'ISR', 'device_role': 'Router', 'platform': 'ios', 'rack': 'Row1RackA', 'position': 1}) => {"ansible_loop_var": "item", "changed": false, "item": {"device_role": "Router", "device_type": "ISR", "name": "R1", "platform": "ios", "position": 1, "rack": "Row1RackA"}, "msg": "Could not resolve id of device_type: isr"}
failed: [netbox1] (item={'name': 'S2', 'device_type': 'ISR', 'device_role': 'Switch', 'platform': 'ios', 'rack': 'Row1RackA', 'position': 5}) => {"ansible_loop_var": "item", "changed": false, "item": {"device_role": "Switch", "device_type": "ISR", "name": "S2", "platform": "ios", "position": 5, "rack": "Row1RackA"}, "msg": "Could not resolve id of device_type: isr"}
changed: [netbox1] => (item={'name': 'S3', 'device_type': 'Nexus9000v', 'device_role': 'Switch', 'platform': 'nxos', 'rack': 'Row1RackB', 'position': 1})
changed: [netbox1] => (item={'name': 'S4', 'device_type': 'vMX', 'device_role': 'Switch', 'platform': 'junos', 'rack': 'Row1RackB', 'position': 5})

Observed Behavior

I'm trying to create device in NetBox via Ansible Playbook, but "device_type" parameter is not working for CSR1000v & IOL based IOS (Virtual L2/L3 Switch). The same block of code and module is working great for Nexus9000v & Juniper vMX.

Inventory details:
R1 - CSR100v
S2 - IOL based IOS
S3 - Nexus9000v
S4 - Juniper vMX

TASK [Create devices] ************************************************************************************************************************************************
task path: /Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/scripts/tasks/device.yaml:82
[WARNING]: Skipping plugin (/Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/lib/python3.8/site-
packages/ansible/plugins/filter/core.py) as it seems to be invalid: cannot import name 'environmentfilter' from 'jinja2.filters'
(/Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/lib/python3.8/site-packages/jinja2/filters.py)
[WARNING]: Skipping plugin (/Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/lib/python3.8/site-
packages/ansible/plugins/filter/mathstuff.py) as it seems to be invalid: cannot import name 'environmentfilter' from 'jinja2.filters'
(/Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/lib/python3.8/site-packages/jinja2/filters.py)
ESTABLISH LOCAL CONNECTION FOR USER: sri
EXEC /bin/sh -c 'echo '"'"'~sri'"'"' && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "echo ~sri/.ansible/tmp"&& mkdir "echo ~sri/.ansible/tmp/ansible-tmp-1667894202.424743-27895-62941890506859" && echo ansible-tmp-1667894202.424743-27895-62941890506859="echo ~sri/.ansible/tmp/ansible-tmp-1667894202.424743-27895-62941890506859" ) && sleep 0'
Using module file /Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/scripts/collections/ansible_collections/netbox/netbox/plugins/modules/netbox_device.py
PUT /Users/sri/.ansible/tmp/ansible-local-27579wxs6elrl/tmpbgqzkor1 TO /Users/sri/.ansible/tmp/ansible-tmp-1667894202.424743-27895-62941890506859/AnsiballZ_netbox_device.py
EXEC /bin/sh -c 'chmod u+x /Users/sri/.ansible/tmp/ansible-tmp-1667894202.424743-27895-62941890506859/ /Users/sri/.ansible/tmp/ansible-tmp-1667894202.424743-27895-62941890506859/AnsiballZ_netbox_device.py && sleep 0'
EXEC /bin/sh -c '/usr/bin/env python /Users/sri/.ansible/tmp/ansible-tmp-1667894202.424743-27895-62941890506859/AnsiballZ_netbox_device.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /Users/sri/.ansible/tmp/ansible-tmp-1667894202.424743-27895-62941890506859/ > /dev/null 2>&1 && sleep 0'
failed: [netbox1] (item={'name': 'R1', 'device_type': 'ISR', 'device_role': 'Router', 'platform': 'ios', 'rack': 'Row1RackA', 'position': 1}) => {
"ansible_loop_var": "item",
"changed": false,
"invocation": {
"module_args": {
"cert": null,
"data": {
"asset_tag": null,
"cluster": null,
"comments": null,
"custom_fields": null,
"device_role": "Router",
"device_type": "ISR",
"face": "front",
"local_context_data": null,
"location": null,
"name": "R1",
"platform": "ios",
"position": 1,
"primary_ip4": null,
"primary_ip6": null,
"rack": "Row1RackA",
"serial": null,
"site": "AVITECHLABS",
"status": "active",
"tags": null,
"tenant": null,
"vc_position": null,
"vc_priority": null,
"virtual_chassis": null
},
"netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"netbox_url": "http://10.0.0.198:8000",
"query_params": null,
"state": "present",
"validate_certs": true
}
},
"item": {
"device_role": "Router",
"device_type": "ISR",
"name": "R1",
"platform": "ios",
"position": 1,
"rack": "Row1RackA"
},
"msg": "Could not resolve id of device_type: isr"
}
EXEC /bin/sh -c 'echo '"'"'~sri'"'"' && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "echo ~sri/.ansible/tmp"&& mkdir "echo ~sri/.ansible/tmp/ansible-tmp-1667894203.591346-27895-188273208312837" && echo ansible-tmp-1667894203.591346-27895-188273208312837="echo ~sri/.ansible/tmp/ansible-tmp-1667894203.591346-27895-188273208312837" ) && sleep 0'
Using module file /Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/scripts/collections/ansible_collections/netbox/netbox/plugins/modules/netbox_device.py
PUT /Users/sri/.ansible/tmp/ansible-local-27579wxs6elrl/tmpmr00fg58 TO /Users/sri/.ansible/tmp/ansible-tmp-1667894203.591346-27895-188273208312837/AnsiballZ_netbox_device.py
EXEC /bin/sh -c 'chmod u+x /Users/sri/.ansible/tmp/ansible-tmp-1667894203.591346-27895-188273208312837/ /Users/sri/.ansible/tmp/ansible-tmp-1667894203.591346-27895-188273208312837/AnsiballZ_netbox_device.py && sleep 0'
EXEC /bin/sh -c '/usr/bin/env python /Users/sri/.ansible/tmp/ansible-tmp-1667894203.591346-27895-188273208312837/AnsiballZ_netbox_device.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /Users/sri/.ansible/tmp/ansible-tmp-1667894203.591346-27895-188273208312837/ > /dev/null 2>&1 && sleep 0'
failed: [netbox1] (item={'name': 'S2', 'device_type': 'ISR', 'device_role': 'Switch', 'platform': 'ios', 'rack': 'Row1RackA', 'position': 5}) => {
"ansible_loop_var": "item",
"changed": false,
"invocation": {
"module_args": {
"cert": null,
"data": {
"asset_tag": null,
"cluster": null,
"comments": null,
"custom_fields": null,
"device_role": "Switch",
"device_type": "ISR",
"face": "front",
"local_context_data": null,
"location": null,
"name": "S2",
"platform": "ios",
"position": 5,
"primary_ip4": null,
"primary_ip6": null,
"rack": "Row1RackA",
"serial": null,
"site": "AVITECHLABS",
"status": "active",
"tags": null,
"tenant": null,
"vc_position": null,
"vc_priority": null,
"virtual_chassis": null
},
"netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"netbox_url": "http://10.0.0.198:8000",
"query_params": null,
"state": "present",
"validate_certs": true
}
},
"item": {
"device_role": "Switch",
"device_type": "ISR",
"name": "S2",
"platform": "ios",
"position": 5,
"rack": "Row1RackA"
},
"msg": "Could not resolve id of device_type: isr"
}
EXEC /bin/sh -c 'echo '"'"'~sri'"'"' && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "echo ~sri/.ansible/tmp"&& mkdir "echo ~sri/.ansible/tmp/ansible-tmp-1667894204.480924-27895-74305332202430" && echo ansible-tmp-1667894204.480924-27895-74305332202430="echo ~sri/.ansible/tmp/ansible-tmp-1667894204.480924-27895-74305332202430" ) && sleep 0'
Using module file /Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/scripts/collections/ansible_collections/netbox/netbox/plugins/modules/netbox_device.py
PUT /Users/sri/.ansible/tmp/ansible-local-27579wxs6elrl/tmpyxbf2uah TO /Users/sri/.ansible/tmp/ansible-tmp-1667894204.480924-27895-74305332202430/AnsiballZ_netbox_device.py
EXEC /bin/sh -c 'chmod u+x /Users/sri/.ansible/tmp/ansible-tmp-1667894204.480924-27895-74305332202430/ /Users/sri/.ansible/tmp/ansible-tmp-1667894204.480924-27895-74305332202430/AnsiballZ_netbox_device.py && sleep 0'
EXEC /bin/sh -c '/usr/bin/env python /Users/sri/.ansible/tmp/ansible-tmp-1667894204.480924-27895-74305332202430/AnsiballZ_netbox_device.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /Users/sri/.ansible/tmp/ansible-tmp-1667894204.480924-27895-74305332202430/ > /dev/null 2>&1 && sleep 0'
changed: [netbox1] => (item={'name': 'S3', 'device_type': 'Nexus9000v', 'device_role': 'Switch', 'platform': 'nxos', 'rack': 'Row1RackB', 'position': 1}) => {
"ansible_loop_var": "item",
"changed": true,
"device": {
"device_role": 2,
"device_type": 3,
"face": "front",
"name": "S3",
"platform": 2,
"position": 1,
"rack": 2,
"site": 1,
"status": "active"
},
"diff": {
"after": {
"state": "present"
},
"before": {
"state": "absent"
}
},
"invocation": {
"module_args": {
"cert": null,
"data": {
"asset_tag": null,
"cluster": null,
"comments": null,
"custom_fields": null,
"device_role": "Switch",
"device_type": "Nexus9000v",
"face": "front",
"local_context_data": null,
"location": null,
"name": "S3",
"platform": "nxos",
"position": 1,
"primary_ip4": null,
"primary_ip6": null,
"rack": "Row1RackB",
"serial": null,
"site": "AVITECHLABS",
"status": "active",
"tags": null,
"tenant": null,
"vc_position": null,
"vc_priority": null,
"virtual_chassis": null
},
"netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"netbox_url": "http://10.0.0.198:8000",
"query_params": null,
"state": "present",
"validate_certs": true
}
},
"item": {
"device_role": "Switch",
"device_type": "Nexus9000v",
"name": "S3",
"platform": "nxos",
"position": 1,
"rack": "Row1RackB"
},
"msg": "device S3 created"
}
EXEC /bin/sh -c 'echo '"'"'~sri'"'"' && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "echo ~sri/.ansible/tmp"&& mkdir "echo ~sri/.ansible/tmp/ansible-tmp-1667894205.7403069-27895-153120847893357" && echo ansible-tmp-1667894205.7403069-27895-153120847893357="echo ~sri/.ansible/tmp/ansible-tmp-1667894205.7403069-27895-153120847893357" ) && sleep 0'
Using module file /Users/sri/Documents/002CaseStudies/Practices/virtual_env/ansible-base2.10.4/scripts/collections/ansible_collections/netbox/netbox/plugins/modules/netbox_device.py
PUT /Users/sri/.ansible/tmp/ansible-local-27579wxs6elrl/tmpfx70kl2b TO /Users/sri/.ansible/tmp/ansible-tmp-1667894205.7403069-27895-153120847893357/AnsiballZ_netbox_device.py
EXEC /bin/sh -c 'chmod u+x /Users/sri/.ansible/tmp/ansible-tmp-1667894205.7403069-27895-153120847893357/ /Users/sri/.ansible/tmp/ansible-tmp-1667894205.7403069-27895-153120847893357/AnsiballZ_netbox_device.py && sleep 0'
EXEC /bin/sh -c '/usr/bin/env python /Users/sri/.ansible/tmp/ansible-tmp-1667894205.7403069-27895-153120847893357/AnsiballZ_netbox_device.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /Users/sri/.ansible/tmp/ansible-tmp-1667894205.7403069-27895-153120847893357/ > /dev/null 2>&1 && sleep 0'
changed: [netbox1] => (item={'name': 'S4', 'device_type': 'vMX', 'device_role': 'Switch', 'platform': 'junos', 'rack': 'Row1RackB', 'position': 5}) => {
"ansible_loop_var": "item",
"changed": true,
"device": {
"device_role": 2,
"device_type": 4,
"face": "front",
"name": "S4",
"platform": 3,
"position": 5,
"rack": 2,
"site": 1,
"status": "active"
},
"diff": {
"after": {
"state": "present"
},
"before": {
"state": "absent"
}
},
"invocation": {
"module_args": {
"cert": null,
"data": {
"asset_tag": null,
"cluster": null,
"comments": null,
"custom_fields": null,
"device_role": "Switch",
"device_type": "vMX",
"face": "front",
"local_context_data": null,
"location": null,
"name": "S4",
"platform": "junos",
"position": 5,
"primary_ip4": null,
"primary_ip6": null,
"rack": "Row1RackB",
"serial": null,
"site": "AVITECHLABS",
"status": "active",
"tags": null,
"tenant": null,
"vc_position": null,
"vc_priority": null,
"virtual_chassis": null
},
"netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"netbox_url": "http://10.0.0.198:8000",
"query_params": null,
"state": "present",
"validate_certs": true
}
},
"item": {
"device_role": "Switch",
"device_type": "vMX",
"name": "S4",
"platform": "junos",
"position": 5,
"rack": "Row1RackB"
},
"msg": "device S4 created"
}

PLAY RECAP ***********************************************************************************************************************************************************

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions