我不断在用户上出错:剧本中的(播放)。 Ansible似乎抱怨结肠,但我尝试的任何方法都无效。
- hosts: all
become: root
tasks:
-name: add user Natasha
user:
- name: natasha
- comment:"Natasha Ping"
- uid: 1027
- group: ping
-name: add user John
user:
- name: john
- comment:"John Pong"
- uid: 1028
- group: ping
预期的结果是将在预期的主机上创建用户natasha和john。
最佳答案
您的YAML语法有错误,很容易修复。如Matthew所述,YAML对间距和分隔符非常严格。
这是您更正的语法:
---
- hosts: all
become: root
tasks:
- name: add user Natasha
user:
name: natasha
comment: "Natasha Ping"
uid: 1027
group: ping
- name: add user John
user:
name: john
comment: "John Pong"
uid: 1028
group: ping
我也建议使用ansible-lint。这将帮助您发现错误并遵循最佳实践。
关于ansible - 如何调试失败的Ansible剧本?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57241172/