Skip to content

[Bug]: Contact Assignment Module modifies existing contact_assignment #1482

@janhoelscher

Description

@janhoelscher

Ansible NetBox Collection version

devel

Ansible version

ansible [core 2.17.6]
  config file = /Users/<hidden>/git/test/netbox-forms/ansible.cfg
  configured module search path = ['/Users/<hidden>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/lib/python3.13/site-packages/ansible
  ansible collection location = /Users/<hidden>/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.13.5 (main, Jun 11 2025, 15:36:57) [Clang 17.0.0 (clang-1700.0.13.3)] (/opt/homebrew/opt/[email protected]/bin/python3.13)
  jinja version = 3.1.4
  libyaml = True

NetBox version

v4.4.2

Python version

3.11

Steps to Reproduce

  1. Create a random contact assignment with a specific role for, in my case, a vm with name
  2. Execute the contact_assignment module to add a contact assignment for the same role but another person

Playbook looks like this:

   - name: "Assign Serveradmins to Contactassignments"
      netbox.netbox.netbox_contact_assignment:
        netbox_url: "{{ nb_host }}"
        netbox_token: "{{ nb_token }}"
        data:
          object_type: virtual_machine
          object_name: "<vm-name>"
          contact: "<name-new-contact>"
          role: "Serveradmin"
        state: present

Expected Behavior

The new created contact assignment should exits, while the other should also exists

Observed Behavior

The first created contact assignment will be overwritten.
So only one exists.

Output looks like this:

changed: [localhost] => {
    "changed": true,
    "contact_assignment": {
        "contact": 513,
        "created": "2025-11-05T13:40:46.755563Z",
        "custom_fields": {},
        "display": "<name-old-contact> -> <vm-name>",
        "id": 1669,
        "last_updated": "2025-11-05T13:40:46.755578Z",
        "object": 903,
        "object_id": 903,
        "object_type": "virtualization.virtualmachine",
        "priority": null,
        "role": 2,
        "tags": [],
        "url": "<netbox-host>/api/tenancy/contact-assignments/1669/"
    },
    "diff": {
        "after": {
            "contact": 513
        },
        "before": {
            "contact": 468
        }
    },
    "invocation": {
        "module_args": {
            "cert": null,
            "data": {
                "contact": "<name-new-contact>",
                "object_name": "<vm-name>",
                "object_type": "virtual_machine",
                "priority": null,
                "role": "Serveradmin",
                "tags": null
            },
            "headers": null,
            "netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "netbox_url": "<netbox-host>",
            "query_params": null,
            "state": "present",
            "validate_certs": true
        }
    },
    "msg": "contact_assignment <name-new-contact> -> <vm-name> updated"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions