June 2020
Intermediate to advanced
410 pages
9h 52m
English
Defining whether a file has the right syntax or not is fairly easy for a machine, but might be more complex for humans. This does not mean that machines are able to fix the code for you, but they can quickly identify whether a problem is present or not. To use Ansible's built-in syntax checker, we need a playbook with a syntax error. Let's get started:
---- hosts: all tasks: - debug: msg: "Hello, World!"
$ ansible-playbook syntaxcheck.yaml --syntax-check
By doing this, we will receive the following output:
ERROR! 'msg' is not a valid attribute for a TaskThe error appears to be in '/home/fale/ansible/Ansible2Cookbook/Ch11/syntaxcheck.yaml': ...