Skip to content

Instantly share code, notes, and snippets.

@darKoram
Created October 14, 2013 20:46
Show Gist options
  • Save darKoram/6981909 to your computer and use it in GitHub Desktop.
Save darKoram/6981909 to your computer and use it in GitHub Desktop.
Demonstrate the unsuitable YAML syntax error when there is a space before "---" leading a vars/main.yml file
---
# note the space before the ---
var1: "val"
# PRODUCES ERROR MESSAGE
# ansible-playbook -i hosts playbooks/test2.yml --limit=localhost
# [' var1', ' "val"']
# ERROR: Syntax Error while loading YAML script, /Users/kbroughton/vcp/git/21ct/proto/lynx-ansible/vars/main.yml
# Note: The error may actually appear before this position: line 3, column 6
# var1: "val"
# ^
# We could be wrong, but this one looks like it might be an issue with
# unbalanced quotes. If starting a value with a quote, make sure the
# line ends with the same set of quotes. For instance this arbitrary
# example:
# foo: "bad" "wolf"
# Could be written as:
# foo: '"bad" "wolf"'
---
- hosts
vars_files:
- main.yml
tasks:
# call a variable in main.yml
- debug: msg="{{var1}}"
@darKoram
Copy link
Author

assuming a suitable hosts file, running the following command reproduces the error.
$ ansible-playbook -i hosts playbook_demo.yml --limit=localhost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment