ANSIBLE::无法解析以下yaml文件中的语法

ANSIBLE::无法解析以下yaml文件中的语法,ansible,yaml,Ansible,Yaml,我正在学习ansible,这是我的YAML文件 ---# Outline to playbook translation - hosts: node1 user: test sudo: yes gather_facts: no tasks: - name: date time stamp at start raw: /usr/bin/date > /home/test/playbook_start.log - name: install apache we

我正在学习ansible,这是我的YAML文件

---# Outline to playbook translation
- hosts: node1
  user: test
  sudo: yes
  gather_facts: no
  tasks:
  - name: date time stamp at start
    raw: /usr/bin/date > /home/test/playbook_start.log
  - name:  install apache web server
    yum: pkg=httpd state=latest
  - name: start the service
    service: name=httd state=restarted
  - name: verify web service is running or not
    command: systemctl status httpd
    register: result
  - debug: var-result
  - name: install client SW telnet
    yum: pkg=telnet state=latest
  - name: install client pkg VIM
    yum: pkg=vim state=latest
我在运行时遇到了这个错误

 ERROR! Syntax Error while loading YAML.


The error appears to have been in '/home/test/Outline/webserver.yml': line 2, column 8, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---# Outline to playbook translation
- hosts: node1
       ^ here
请尝试此文件:

---
# Outline to playbook translation
- hosts: node1
  user: test
  sudo: yes
  gather_facts: no
  tasks:
  - name: date time stamp at start
    raw: /usr/bin/date > /home/test/playbook_start.log
  - name:  install apache web server
    yum: pkg=httpd state=latest
  - name: start the service
    service: name=httd state=restarted
  - name: verify web service is running or not
    command: systemctl status httpd
    register: result
  - debug: var=result
  - name: install client SW telnet
    yum: pkg=telnet state=latest
  - name: install client pkg VIM
    yum: pkg=vim state=latest

语法错误是因为您没有位于前面标记(指令结束标记:
--
)中文件的第一行:

注释必须用空格字符与其他标记隔开

尝试:


要么删除“#大纲到剧本翻译”,要么将其放在下一行,要么在--

您的右侧后面留出一个空格,我从我的回复中删除了这一行(我在个人资料中修复了文本)。
--- # Outline to playbook translation