playbook安装lamp
时间: 2023-06-23 13:58:56 浏览: 55
好的,以下是安装LAMP环境的Playbook:
```yaml
- name: Install LAMP stack
hosts: all
become: true
tasks:
- name: Install Apache
apt:
name: apache2
state: present
- name: Install MySQL
apt:
name: mysql-server
state: present
- name: Install PHP
apt:
name: php
state: present
- name: Install PHP modules
apt:
name: "{{ item }}"
state: present
with_items:
- php-mysql
- libapache2-mod-php
- name: Restart Apache
service:
name: apache2
state: restarted
```
在这个Playbook中,我们使用了`apt`模块来安装所需的软件包。安装完成后,我们重新启动了Apache服务,以确保配置生效。
你可以将这个Playbook保存为一个`.yml`文件,然后使用`ansible-playbook`命令来运行它。