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))