我正在尝试编写一个安装Apache的剧本,但我收到以下错误:
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
这里可能有什么问题?
答案 0 :(得分:4)
您无法在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