码迷,mamicode.com
首页 > 其他好文 > 详细

ansible批量部署nginx

时间:2017-08-29 12:46:41      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:code   安装包   file   nginx 安装   nbsp   local   prefix   error   ref   

1.1 将nginx的安装包,和安装脚本copy到客户端,并安装脚本

vim /ansible/roles/nginx/tasks/main.yml

- name: copy nginx_tar_gz to client
  copy: src=nginx-1.8.0.tar.gz dest=/tmp/nginx-1.8.0.tar.gz
- name: copy install_shell to client
  copy: src=install_nginx.sh dest=/tmp/install_nginx.sh
- name: install nginx
  shell: /bin/bash /tmp/install_nginx.sh

1.2 Nginx 安装脚本

vim /ansible/roles/nginx/files/install_nginx.sh

#!/bin/bash
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
groupadd -r nginx
useradd -s /sbin/nologin -g nginx -r nginx
cd /tmp
tar xf nginx-1.8.0.tar.gz;cd nginx-1.8.0
mkdir /application/nginx/;chown nginx.nginx /application/nginx/
./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/application/nginx/nginx.pid --user=nginx --group=nginx --with-http_ssl_module
make && make install
egrep -v "#|^$" /etc/nginx/nginx.conf >/etc/nginx/nginx.conf.bak
rm -rf /etc/nginx/nginx.conf
mv /etc/nginx/nginx.conf.bak /etc/nginx/nginx.conf
sed -i  "/^\s*index / i proxy_pass http://localhost:8080;" /etc/nginx/nginx.conf
/usr/sbin/nginx

 

ansible批量部署nginx

标签:code   安装包   file   nginx 安装   nbsp   local   prefix   error   ref   

原文地址:http://www.cnblogs.com/Carr/p/7447325.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!