ansible - 我只是试图在每个剧本中写一个相同的错误
问题描述
--- # this is first playbook with handler
- host: demo
user: ansible
become: yes
connection: ssh
vars:
pkgname: httpd
task:
- name: install httpd service
action: yum name='{{pkgname}}' state=installed
notify: restart httpd
handler:
- name: restart httpd
action: service name=httpd state=restarted
ERROR! 'task' is not a valid attribute for a Play
The error appears to be in '/home/ansible/handler.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
--- # this is first playbook with handler
- host: demo
^ here
解决方案
我认为是tasks:
(复数),不是task:
推荐阅读
- oracle - 过滤数据时未在预期位置找到 FROM 关键字
- linux - 运行仅影响其中一台主机的 playbook 时出错
- android - Smali:修改方法以返回 True
- python - TensorFlow 在“创建 TensorFlow 设备”后卡住
- python - Python 字典(/w 值是各种长度的列表)到 Pandas 数据框
- python - 创建多通道网络:“连接”对象没有属性“形状”
- java - 及时绑定在 guice
- android - 相机方向 横向 Android Zxing
- javascript - JavaScript。const addName = name => ({firstnmae : name}) 和 addName2 = (name) => { {firstname : name }} 有什么区别
- terraform - 在 variavles.tf 中为 type = map(object()) 添加默认字段