YAML语法错误(Ansible playboook)
我想写安装Apache一个剧本,但我得到了以下错误:YAML语法错误(Ansible playboook)
The offending line appears to be: tasks:
- name: command to install apache
^here
这里是我的YAML代码:
--- - hosts: all
tasks:
- name: command to install apache
sudo: yes
yum: name=httpd state=latest
service: name=httpd state=running
有什么事情这里错了吗?
回答:
您不能将两个操作(模块)添加到Ansible中的单个任务。
您需要将yum
和service
分成两个任务。
而且sudo
宣言很久以前的过时,现在become
应使用:
--- - hosts: all
tasks:
- name: Ensure apache is installed
become: yes
yum: name=httpd state=latest
- name: Ensure httpd service is running
become: yes
service: name=httpd state=running
以上是 YAML语法错误(Ansible playboook) 的全部内容, 来源链接: utcz.com/qa/264136.html