进入vim nginx.yml
- hosts: webservers
tasks:
- name: "安装LNMP相关组件"
yum:
name: gcc,pcre-devel,zlib-devel,mysql,mysql-server,php,php-mysql,php-fpm
state: latest
- name: "推送Nginx源码包"
unarchive:
src: nginx-1.11.2.tar.gz
dest: /root/
- name: "分发脚本安装nginx"
script: lnmp.sh
- name: "推送配置文件"
copy:
src: nginx.conf
dest: /usr/local/nginx/conf/nginx.conf
- name: "启动nginx"
shell: /usr/local/nginx/sbin/nginx
- name: "启动MySQL"
service:
name: mysqld
state: started
- name: "启动php"
service:
name: php-fpm
state: started
- name: "推送Discusz"
unarchive:
src: Discuz_X3.3_SC_UTF8.zip
dest: /usr/local/nginx/html/
mode: 0777
- name: "复制文件到网站根目录"
tags: page
shell: cd /usr/local/nginx/html/ && \cp -r upload/* ./ && chmod -R 777 *
ansible-playbook aaa.yml (运行剧本)