Problem scenario
You run an Ansible playbook with a variable. But you get this message: "ERROR! Syntax Error while loading YAML. expected , but found ''" (Ansible found blank single quotes or a double quote mark.)
How do you get the playbook to run?
Solution
Notice the "offending line" in the message. Remove the braces and possibly the quotes around the braces. Assign the variable by itself (without the braces syntax).
Do not use a variable like this:
tasks:
- shell: "echo > /tmp/date.txt"
when: {{ ansible_hostname }} == "contintserver"
or like this:
- shell: "echo > /tmp/date.txt"
when: "{{ ansible_hostname }}" == "contintserver"
Here would be a correct snippet:
- shell: "echo > /tmp/date.txt"
when: ansible_hostname == "contintserver"