运行剧本出错:
ERROR! Syntax Error while loading YAML.
did not find expected '-' indicator
The error appears to have been in '/etc/ansible/nginx_install/roles/nginx/tasks/main.yaml': line 3, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: install nginx package
yum: name={{ item }} state=latest
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
按照提示的意思是,注意空格,也就是缩进,好好调整即可解决
本文详细解析了在运行Ansible剧本时遇到的错误:SyntaxError while loading YAML,具体表现为未找到预期的'-'指示符。文章指出问题可能源于YAML语法错误,如缩进不当或模板表达式缺少引号,并提供了正确的示例代码。

2378

被折叠的 条评论
为什么被折叠?



