我刚刚开始尝试使用ansible,我正在尝试编写我的第一个简单的剧本。 但是我的任务键工作语法错误
---
name: add ansible user
hosts: all
become: true
become_method: sudo
become_user:root
tasks:
- user:
name: ansible
groups: ansible
当我运行时,请获取以下内容:
utility:~/scripts/ansible# ansible-playbook --check add-ansible-user.yml
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/root/scripts/ansible/add-ansible-user.yml': line 8, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
^ here
从搜索中我相信最好的选择是我有一个缩进问题,但无论如何我试图改变它,我不能让它工作太多。
答案 0 :(得分:1)
- name: add ansible user
hosts: all
become: true
become_method: sudo
become_user: root
tasks:
- user:
name: ansible
groups: ansible
这确实是缩进问题。请尝试上面写的代码。
答案 1 :(得分:0)
问题在这里:
become_user:root
您需要在:
和root
之间留一个空格
become_user: root