Skip to content

netbox_ip_address cannot be used with VMs #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bluikko opened this issue Apr 3, 2020 · 2 comments
Closed

netbox_ip_address cannot be used with VMs #156

bluikko opened this issue Apr 3, 2020 · 2 comments

Comments

@bluikko
Copy link
Contributor

bluikko commented Apr 3, 2020

ISSUE TYPE
  • Bug Report
SOFTWARE VERSIONS
Ansible:

2.9.6

Netbox:

2.6.1

Collection:

0.1.10

SUMMARY

Trying to add an IP address to a VM with netbox_ip_address fails. This seems to be similar to the bug in the Ansible bundled Netbox module.

STEPS TO REPRODUCE
- name: Add IP address
  netbox.netbox.netbox_ip_address:
    netbox_url: "{{ netbox }}"
    netbox_token: "{{ token }}"
    data:
      family: 4
      address: "{{ ipv4 }}"
      interface:
        name: Eth0
        device: "{{ vmname }}"
      status: Active
      tenant: Test
    state: present
EXPECTED RESULTS

IP address should be assigned to the VM.

ACTUAL RESULTS

An error is displayed:

"msg": "{\"device_id\":[\"Enter a number.\"]}"
@bluikko
Copy link
Contributor Author

bluikko commented Apr 4, 2020

As discussed in the similar issue with inventory, there should be a parameter "vm" in addition to "device" parameter to manipulate IP addresses of VMs:

- name: Add IP address
  netbox.netbox.netbox_ip_address:
    netbox_url: "{{ netbox }}"
    netbox_token: "{{ token }}"
    data:
      family: 4
      address: "{{ ipv4 }}"
      interface:
        name: Eth0
        virtual_machine: "{{ vmname }}"
      status: Active
      tenant: Test
    state: present

This currently fails with Enter a number.. A more clear error message could also be good, "Could not find device" or something similar?

@bluikko
Copy link
Contributor Author

bluikko commented Apr 4, 2020

My bad, I had a typo. An endpoint can be found by using "virtual_machine" instead of "device".

So since devices and virtual_machines are different IDs, I understand the reasoning why both couldn't be searched with a single endpoint parameter. It will be more code in Ansible to handle devices and VMs separately but I guess it is needed, it is the only way to handle case where same name is shared by both a device and a VM.

@bluikko bluikko closed this as completed Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant