--syntax-check fails on 1.4.with ERROR: MODULE is not a legal parameter in an Ansible Playbook

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.

This is the ticket: https://github.com/ansible/ansible/issues/5412

–syntax-check fails on 1.4.with ERROR: MODULE is not a legal parameter in an Ansible Playbook

The --syntax-check option does not work for me. Ansible 1.4.3, installed via pip on OS X 10.9.

Basic playbook which consists out of a few roles:

cat ./playbooks/default-vps-setup.yml

Saw your ticket, as stated, it could not be reproduced.

– Michael

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.

It is run on the YAML files because when run on just the playbook which includes the roles it does not check the includes roles.

And, as also can be seen in the ticket, checking of all the YAML files with Ansible 1.3 did work just fine.

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.

Even when a broken playbook or a broken yaml file is includes as role it validates as correct with 1.4.

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.

– Michael

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:

ansible-playbook --syntax-check --list-tasks site.yml

Seems logical. Can you maybe explain why it worked in 1.3 on task files?

And that one does work with 1.4:

ansible-playbook --syntax-check --list-tasks -i tests/ansible_hosts ./playbooks/default-vps-setup.yml

[…]

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

  • apt:“;;::D”‘’:d;dsfds pkg=vim-tiny state=latest update_cache=yes
    sudo: yes
    ^

Thank you both Michael and Mart.

Doesn’t matter as it is for playbooks.

– Michael

OK. Yet again, thanks for the help.

OK. Yet again, thanks for the help.