Since my bug report is ignored and closed I’m asking for support here. Since the upgrade to Ansible 1.4 the --syntax-check feature broke when used with role files.
I believe the issue is that you are running a --syntax-check against something that is not a playbook. The error message actually states that as well:
"ERROR: apt is not a legal parameter in an Ansible Playbook”
And that is a correct error, as ‘apt’ is not a legal parameter in a playbook.
From the looks of things, you are running --syntax-check against yaml files from a role.
The syntax of a playbook and a role are inherently different.
When you do a --syntax-check on a playbook, it will run through the entirety of the playbook, all includes, etc…and return the status of the full syntax check.
Is there a reason you are attempting to run it on all yaml files and not just running it on your playbooks? Seems like you are taking some unnecessary steps.
I can clearly reproduce it with my set of playbooks here. Did you try it with the playbook in the ticket? As in, the playbook and the vim role. That alone gives the error on 1.4 and not on 1.3.
This command is only intended for running on the top level playbook. It is not intended for running directly on task files which are by definition not playbooks.
Sorry, I forgot to mention, when looking through the code, I realized in order to get it to check all the roles too, you need to use the --list-tasks argument too:
ERROR: Syntax Error while loading YAML script, /home/remy/ansible/playbooks/roles/vim/tasks/main.yml
Note: The error may actually appear before this position: line 3, column 7