Did not find expected ‘-‘ indicator while parsing a block collection

I ran into this pesky error the other day while working on an ansible script and when I tried debugging the file (using yamllint.com) it pointed me to a completely different part of the .yml file (i.e. at line 2 column 1). But, the error actually existed much further down in the .yml file. Here’s the snippet that was the cause of the problem:

 - name: command module that throws an error
  command: example command

You probably can’t see the issue just by looking at the code above but there is an extra space in front of the ” – name: command module that throws an error” that was the issue. So, I had to replace the above code with the below, and I was good to go:

- name: command module that throws an error
  command: example command

So, check that you don’t have any spaces in front of “– name:” at any point in your .yml file, as that could be one of the solutions for why the “Did not find expected ‘-‘ indicator while parsing a block collection” error was thrown.

Leave a Reply

Your email address will not be published. Required fields are marked *