Why is this telling me the variable is undefined?

I tried to follow along with a similar approach to the docs on read_csv here. 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"}

Here’s what my playbook looks like:

`

You are missing the dash in front of set_fact.

I get an error stating:

`
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to have been in ‘system_info.yaml’: line 7, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

tasks:

  • name: Read the CSV & Set Values
    ^ here
    `

That’s with my file being reworked to:

`

From the docs:

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

Regards
         Racke

Your indentation is wrong.

try:

path: is not indented?

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:

- debug:
    var: system
- debug:
    var: system.csv

Appreciate the responses so far everyone. I’ve indented the path line as suggested but still get the following error:

`

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to have been in ‘system_info.yaml’: line 7, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

tasks:

  • name: Read the CSV & Set Values
    ^ here
    `

Here’s the latest of what my file currently looks like:

`

Hello,

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.

Hopefully this helps

Woohoo, that was it. Updated and it’s working now. Thanks a lot, checking my version was the last thing on my mind for whatever reason