Skip to content

Commit 928621f

Browse files
BugFix: Jinja template always passes in string, allowed find_ids method to account for that (#132)
1 parent f1d2260 commit 928621f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

plugins/module_utils/netbox_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,15 @@ def _find_ids(self, data):
567567
query_params = {QUERY_TYPES.get(k, "q"): search}
568568
query_id = self._nb_endpoint_get(nb_endpoint, query_params, k)
569569

570+
# Code to work around Ansible templating converting all values to strings
571+
# This should allow users to pass in IDs obtained from previous tasks
572+
# without causing the module to fail
573+
if isinstance(v, str):
574+
try:
575+
v = int(v)
576+
except ValueError:
577+
pass
578+
570579
if isinstance(v, list):
571580
data[k] = id_list
572581
elif isinstance(v, int):

0 commit comments

Comments
 (0)