From e609d52c01eb8897a309d86675856c946f9d85ca Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Tue, 21 Nov 2023 16:09:34 +0100 Subject: [PATCH] csvfile - let the config system do the typecasting. --- changelogs/fragments/csvfile-col.yml | 4 ++++ lib/ansible/plugins/lookup/csvfile.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/csvfile-col.yml diff --git a/changelogs/fragments/csvfile-col.yml b/changelogs/fragments/csvfile-col.yml new file mode 100644 index 00000000000..5b155fde471 --- /dev/null +++ b/changelogs/fragments/csvfile-col.yml @@ -0,0 +1,4 @@ +--- + +minor_changes: + - csvfile - let the config system do the typecasting. diff --git a/lib/ansible/plugins/lookup/csvfile.py b/lib/ansible/plugins/lookup/csvfile.py index 778138847ae..76a21b4ac4f 100644 --- a/lib/ansible/plugins/lookup/csvfile.py +++ b/lib/ansible/plugins/lookup/csvfile.py @@ -15,7 +15,8 @@ DOCUMENTATION = r""" options: col: description: column to return (0 indexed). - default: "1" + default: 1 + type: int keycol: description: column to search in (0 indexed). default: 0 @@ -135,7 +136,7 @@ class LookupModule(LookupBase): for row in creader: if len(row) and row[keycol] == key: - return row[int(col)] + return row[col] except Exception as e: raise AnsibleError("csvfile: %s" % to_native(e))