Skip to content
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

[Bug]: netbox_service finds multiple addresses instead of one #470

Closed
fheinonen opened this issue Mar 15, 2021 · 1 comment · Fixed by #718
Closed

[Bug]: netbox_service finds multiple addresses instead of one #470

fheinonen opened this issue Mar 15, 2021 · 1 comment · Fixed by #718
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed PR Required

Comments

@fheinonen
Copy link

fheinonen commented Mar 15, 2021

ISSUE TYPE
  • Bug Report
SOFTWARE VERSIONS
Ansible:

2.10.6

Netbox:

2.10.5

Collection:

3.0.0

SUMMARY

netbox_service returns "msg": "More than one result returned for ipaddresses" when specifying virtual_machine id or name

STEPS TO REPRODUCE
  1. add two virtual machines with both having a loopback interface with address 127.0.0.1/8
  2. Add services with netbox.netbox.netbox_service module with an 127.0.0.1/8 IP address
   - name: Gather facts on listening ports
     community.general.listen_ports_facts:
     become: True

   - name: Create TCP or UDP loopback service
      netbox.netbox.netbox_service:
        netbox_url: "{{ lookup('ENV', 'NETBOX_URL') }}"
        netbox_token: "{{ lookup('ENV', 'NETBOX_API_KEY') }}"
        data:
          virtual_machine: "{{ inventory_hostname }}"
          name: "{{ item.name }}"
          port: "{{ item.port }}"
          protocol: "{{ item.protocol }}"
          ipaddresses: 
            - address: 127.0.0.1/8
        state: present
      delegate_to: localhost
      when: item.address == "127.0.0.1"
      loop: "{{ ansible_facts.tcp_listen + ansible_facts.udp_listen }}"
EXPECTED RESULTS

Expecting netbox to find one virtual machine loopback interface address, instead of multiple

ACTUAL RESULTS

The following error happened when running the playbook: "msg": "More than one result returned for ipaddresses"

   "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "data": {
                "custom_fields": null,
                "description": null,
                "device": null,
                "ipaddresses": {
                    "address": "127.0.0.1/8"
                },
                "name": "chronyd",
                "port": 323,
                "ports": null,
                "protocol": "udp",
                "tags": null,
                "virtual_machine": "machine1.example.com"
            },
            "netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "netbox_url": "https://netbox.example.com",
            "query_params": null,
            "state": "present",
            "validate_certs": true
        }
    },
@FragmentedPacket FragmentedPacket added bug Something isn't working help wanted Extra attention is needed PR Required labels May 9, 2021
@ryanmerolle ryanmerolle changed the title netbox_service finds multiple addresses instead of one [Bug]: netbox_service finds multiple addresses instead of one Jan 25, 2022
@rodvand rodvand self-assigned this Feb 1, 2022
@julianze
Copy link

julianze commented Jun 22, 2022

Is this really fixed?
I had the issue last year and found this issue. After updating to 3.7.1 the error is still permanent.

Ansible 2.10.8 with Python 3.7.3
Netbox 2.11.10
pynetbox: 6.1.2
Netbox-Collection: 3.7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed PR Required
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants