You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone,
I have a role in one of my playbooks that is supposed to get a list of VMs owned by a user. I query the owner tag by the username to get this list:
# ROLE: INSTANCE_GET_OWNER
---
- name: Variables validationassert:
that:
- username is definedfail_msg: "[ERROR] Missing required variable"
- name: Get VM properties from CMDB via APIuri:
url: "https://netbox.domain/api/virtualization/virtual-machines/?cf_owner={{ username }}"headers:
Accept: "application/json"Authorization: "Token aaaaaaaaaaaa"method: "GET"body_format: "json"register: vm
- name: _FACTS_set_fact:
user_vm_list: "{{ vm.json | json_query('results[*].display') }}"
- name: Printing vm owner detailsansible.builtin.debug:
msg: "{{ user_vm_list }}"
The issue is that the text which is entered under {{ username }} seems to act like a wildcard, which is true to the web interface itself.
For example, I can query for jon which would return anything with jon in it: ajona, jonb, etc. It's as if I wrote *jon*. How can I make sure to return exactly what I need?
Thanks :)
Edit: after googling a bit more, I found the ie attribute which should be is exactly. Sorry for opening the thread.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello everyone,
I have a role in one of my playbooks that is supposed to get a list of VMs owned by a user. I query the
owner
tag by the username to get this list:The issue is that the text which is entered under
{{ username }}
seems to act like a wildcard, which is true to the web interface itself.For example, I can query for
jon
which would return anything withjon
in it:ajona
,jonb
, etc. It's as if I wrote*jon*
. How can I make sure to return exactly what I need?Thanks :)
Edit: after googling a bit more, I found the
ie
attribute which should be is exactly. Sorry for opening the thread.Beta Was this translation helpful? Give feedback.
All reactions