If someone could explain the logic behind one string working and the other not then that’d be helpful. I think this is a bug in ansible’s yaml parser.
https://github.com/ansible/ansible/issues/14783
I tried looking for the code that produces the “Be sure to quote variables…” AnsibleError but didn’t find it on master.