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

Can't set virtual machine role in netbox_virtual_machine #314

Closed
garbled1 opened this issue Aug 23, 2020 · 1 comment · Fixed by #327
Closed

Can't set virtual machine role in netbox_virtual_machine #314

garbled1 opened this issue Aug 23, 2020 · 1 comment · Fixed by #327
Labels
bug Something isn't working PR Submitted

Comments

@garbled1
Copy link

ISSUE TYPE
  • Bug Report
SOFTWARE VERSIONS
Ansible:

ansible 2.9.1
config file = /home/awx/.ansible/collections/ansible_collections/netbox/netbox/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.7/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]

Netbox:

2.8.5

Collection:

1.0.0

SUMMARY

When attempting to set virtual_machine_role, ansible always returns "More than one result returned for virtual_machine_role"

STEPS TO REPRODUCE
- name: Create VM in netbox
  netbox.netbox.netbox_virtual_machine:
    netbox_url: '{{ netbox_server }}'
    netbox_token: '{{ netbox_token }}'
    data:
      name: '{{ inventory_hostname_short }}'
      cluster: '{{ vm_cluster }}'
      virtual_machine_role: 'Server'
      status: 'Active'
      tags:
        - VM
  register: vm_info
  delegate_to: localhost
EXPECTED RESULTS

Expect it to find a device role

ACTUAL RESULTS

instead I think it searches "vm_role", which is a true/false. If I search that with the API, I get all 25 results. If there is some magic required here, I don't understand it.

{
    "msg": "More than one result returned for virtual_machine_role",
    "changed": false,
    "invocation": {
        "module_args": {
            "netbox_url": "mine",
            "netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "data": {
                "name": "antares",
                "cluster": "Hydra",
                "virtual_machine_role": "Server",
                "status": "Active",
                "tags": [
                    "VM"
                ],
                "site": null,
                "vcpus": null,
                "tenant": null,
                "platform": null,
                "primary_ip4": null,
                "primary_ip6": null,
                "memory": null,
                "disk": null,
                "custom_fields": null
            },
            "state": "present",
            "validate_certs": true,
            "query_params": null
        }
    },
    "_ansible_no_log": false,
    "_ansible_delegated_vars": {}
}
@FragmentedPacket
Copy link
Contributor

@garbled1 Do you mind testing attached PR to see if your issue is resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR Submitted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants