I have put together some offline and online methods to check your Ansible syntax for errors.
1: Check Mode (Dry Run): When ansible-playbook is executed with –check it will not make any changes on remote systems. Instead, any module instrumented to support ‘check mode’ (which contains most of the primary core modules, but it is not required that all modules do this) will report what changes they would have made rather than making them. Other modules that do not support check mode will also take no action but just will not report what changes they might have made.
Check mode is just a simulation, and if you have steps that use conditionals that depend on the results of prior commands, it may be less useful for you. However, it is great for one-node-at-time basic configuration management use cases.
ansible-playbook dc.yml --check
2: YAML Lint: http://www.yamllint.com/ Below is a simple playbook as pasted below.
– Click on Go in order to validate the syntax for errors
Below are some lists of other YML validators