I tried to follow along with a similar approach to the docs on read_csvhere. I’m not sure why I’m getting this error returned when the value of systems is defined just above the set_fact:
fatal: [127.0.0.1]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'systems' is undefined\n\nThe error appears to have been in 'system_info.yaml': line 7, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: Read the CSV & Set Values\n ^ here\n"}
# Read a CSV file and access the first item
- name: Read users from CSV file and return a list
read_csv:
path: users.csv
register: users
delegate_to: localhost
You need to intend the parameters for the Ansible module (path in your case).
Your original spacing looks fine other than missing the dash for set fact. The original error is indicating that the "system" doesn't exist when your CSV read task looks for "system.csv". I would check that "system.csv" is defined and add this before the csv read task to troubleshoot:
I was having a moment earlier when I read your path as an actual variable that was my mistake. To be more helpful though, I replicated your code on my setup and ran into the same error. On checking the docs I saw that read_csv was added in 2.8, and after updating to 2.8 the “no action detected in task” error is gone.