安装ansible 配置主机 这里就不写了
1.编写playbook
---
- hosts: webservers
vars:
- ROOT: /opt/html
- PORT: 80
tasks:
- name : '配置班级源'
script: repo.sh
- name : '安装httpd和lamp的相关组件'
yum: name=httpd,php,php-gd,php-mysql state=latest
- name: '分发配置文件支持php'
template: src=httpd.conf dest=/etc/httpd/conf/httpd.conf
- name: '创建目录'
file: path={{ROOT}} state=directory owner=apache group=apache
- name: '分发主界面'
template: src=info.php dest={{ROOT}}/info.php
- name: '关闭防火墙'
service: name=iptables state=stopped
- name: '关闭selinux'
shell: setenforce 0
- name: '启动httpd'
service: name=httpd state=restarted enabled=yes
~
2.编写一个主界面
<h1>{{ansible_hostname}}</h1>
<h1>{{ansible_all_ipv4_addresses}}</h1>
<?php
phpinfo();
?>
3.编写hppd的配置文件 默认访问界面 改为index.php
AddType application/x-httpd-php .php