首页 > 解决方案 > 我只是试图在每个剧本中写一个相同的错误

问题描述

--- # 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

标签: ansible

解决方案


我认为是tasks:(复数),不是task:


推荐阅读