YAml文件错误:找不到预期的密钥

时间:2018-04-11 07:09:08

标签: ansible ubuntu-16.04

我正在尝试在ubuntu 16.04LTS中执行ansible工具的YAML文件。该文件在localhost上安装nginx。以下是我的代码:

---
- hosts: localhost
  become: yes
  tasks:
    - name: Installs Nginx web server
      apt: pkg=nginx state=installed update_cache=true
      notify:
        - start nginx

    - name: Upload default index.html for host
      copy: src=~/Documents/index.html dest=/usr/share/nginx/html/ mode=0644



  handlers:
    - name: start nginx
      service: name=nginx state=started

现在,此代码在联机Yaml解析器中正常运行,但在终端中出现以下错误:

ERROR! Syntax Error while loading YAML.
 did not find expected key

The error appears to have been in '/root/nginx.yml':line 13, column 4, 
but 
may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

handlers:
^ here

任何人都可以帮助我。

1 个答案:

答案 0 :(得分:0)

问题解决了。字处理程序之前有一个额外的空格