老师,我这个 yaml 总是报语法错误,

来源:6-16 playbook剧本中用的yaml配置语法

sunshinebao

2018-05-12

---
- hosts : 192.168.226.129
  remote_user : root
   vars:
        touch_file : imoocc.file
    task :
       - name : touch file
         shell : "touch /tmp/{{touch_file}}"


ansible-playbook f1.yml --syntax-check
ERROR! Syntax Error while loading YAML.


The error appears to have been in '/etc/ansible/f1.yml': line 4, column 9, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  remote_user : root
   vars :
        ^ here

exception type: <class 'yaml.scanner.ScannerError'>
exception: mapping values are not allowed here
  in "<unicode string>", line 4, column 9:
       vars :
            ^

写回答

1回答

sunshinebao

提问者

2018-05-12

老师,这个问题,已经解决了,应该是层级没对齐原因,现在可以运行了

0
0

Python+Django+Ansible Playbook自动化运维项目实战

【课程升级3.6版本】大牛全面践行DevOps,运维与开发间高效协作

861 学习 · 326 问题

查看课程