ansible - 错误!“通知”不是 Play 的有效属性
问题描述
我正在尝试使用 Ansible-playbook 安装 LAMP。但我收到错误[如图所示]
我用于剧本的代码如下:-
---
- hosts: all
become: yes
tasks:
- name: Install httpd
yum:
name: httpd
state: present
notify:
- restart apache
- name: starting httpd service
service:
name: httpd
enabled: yes
state: started
- name: Installing php packages
yum:
name: "{{ item }}"
state: present
with_items:
- php
- php-mysql
- php-pdo
- php-gd
- php-mbstring
notify:
-restart apache
handlers:
- name: restart apache
service:
name: httpd
state: restarted
解决方案
您的缩进不正确。这应该有效:
---
- hosts: all
become: yes
tasks:
- name: Install httpd
yum:
name: httpd
state: present
notify:
- restart apache
- name: starting httpd service
service:
name: httpd
enabled: yes
state: started
- name: Installing php packages
yum:
name: "{{ item }}"
state: present
with_items:
- php
- php-mysql
- php-pdo
- php-gd
- php-mbstring
notify:
- restart apache
handlers:
- name: restart apache
service:
name: httpd
state: restarted
推荐阅读
- android - Android Instrumentation 测试在哪个进程中运行?
- opengl-es - 未能添加服务 - 已在使用错误
- flutter - Flutter DateTimeFormField 提示文本颜色不变
- javascript - 从给定数字中找出奇数
- python - Pandas:如何从数据框中现有列中的值创建新列?
- swiftui - SwiftUI:如何在 ListView 中使用绑定变量
- python - 如何将“搜索栏”链接到搜索视图 Django
- git - 如何重用已推送到远程的标签以用于稍后合并的代码
- php - nginx - php connect() unix socket 失败
- html - 如何使用两个指向同一元素的链接,一个作为主链接,另一个作为 HTML 中的故障保护?