Which spellings does Ansible's YAML accept for true and false, and which form should you write?
Besides true/false, YAML 1.1 accepts forms like yes/no, on/off and their capitalised variants; write plain true and false, the only booleans in YAML 1.2.
* 22 spellings in the YAML 1.1 type: 11 for true and 11 for false. *
The YAML 1.1 boolean type lists 22 accepted tokens in total, 11 meaning true and 11 meaning false:
| Meaning | YAML 1.1 tokens |
|---|---|
| true | y Y yes Yes YES true True TRUE on On ON |
| false | n N no No NO false False FALSE off Off OFF |
Ansible's parser (PyYAML) implements all of these except the single letters, so y and n stay strings. Inside a conditional, the table on the Ansible side also lists 1 and 0.
The YAML 1.2 standard keeps only true and false, which is why the community is drifting towards writing only those two. The looser rules cause real bugs: the country code NO (Norway) in a list silently becomes False. Writing true/false and quoting strings that look like booleans avoids the whole class of problem.
Go deeper:
Boolean Language-Independent Type for YAML 1.1 (yaml.org) — the spec page with the full regular expression.
The Norway Problem (StrictYAML) — how implicit booleans break real configuration files.
YAML (Wikipedia) — the language, its versions and its criticisms.