I've got the below play wherein I'm trying to stop WAS instances on an AIX server.

---

- hosts: all

vars_files:

- /etc/ansible/conf/var.yml

tasks:

- name: stop websphere instances

script: {{ was_script }} {{ item }}

with_items: "{{ was_inst }}"

The was_script and was_inst are listed as variable in var.yml. Now if I hardcode the script instead of was_script it works. But it's not working if I call it as a variable.

It says it's a YAML syntax error, but I can't seem to figure out what the error is.

网友答案:

The arrow ^ here is pointing to the script: {{ was_script }} {{ item }} line.
You should quote it script: "{{ was_script }} {{ item }}", because it starts with braces.
There's a note about YAML gotchas in the docs.