Ansible Playbook: ERROR! ‘command’ is not a valid attribute for a Play

Question:

I’m just trying to write a basic playbook, and keep getting the error below.
Tried a tonne of things but still can’t get it right. I know it must be a syntax thing but no idea where.

This is the code I have:

This is the error I get:

Ansible ver: 2.4.2.0

It’s driving me insane. I’ve looked at some examples from the Ansible docs, and it looks the same.
No idea…

Anyone know?

Answer:

The problem being that without the indentation of the command line the command directive is part of the overall play and not the task block. i.e. the command should be part of the task block.

Leave a Reply