继续学习ansible-playbook的使用,熟悉使用更多jinja2模板语法,下面是我的脚本,后面会继续完善,使用更多的模板语法
nginx.yml文件
---
- hosts: node
remote_user: root
vars:
target_dir: '/usr/local/src/'
nginx_version: '1.17.4'
tasks:
- name: 安装依赖包
shell: yum install -y make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel cmake
- name: 复制nginx文件
copy: src=nginx-{{ nginx_version }}.tar.gz dest={{ target_dir }}
- name: 复制一键安装脚本
copy: src=nginx_install.sh dest={{ target_dir }} mode=0755
- name: 执行一件安装脚本
shell: /bin/bash {{ target_dir }}nginx_install.sh {{ nginx_version }}nginx安装脚本
#!/bin/bash
nginx_dir='/usr/local/nginx'
if [ ! -e ${nginx_dir} ]
then
mkdir -p ${nginx_dir}
fi
cd /usr/local/src
if [ ! -z $1 ]
then
tar -zxvf nginx-$1.tar.gz
else
exit 1
fi
cd nginx-$1
groupadd www
useradd -g www www -s /sbin/nologin
./configure --prefix=${nginx_dir} --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-http_realip_module --with-pcre
make && make install
if [ $? -ne 0 ]
then
exit 1
fi
/usr/local/nginx/sbin/nginx需要提前下好nginx源码包放置nginx.yml同一目录
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://sulao.cn/post/720
相关阅读
- linux使用pdsh/pdcp批量操作服务器和批量编译nginx实际操作
- ubuntu22.04编译安装nginx
- flask使用nginx代理以后图片上传和加载问题解决方法
- nginx反向代理http/https、rpc/grpc、ws/wss
- nginx四层负载均衡配置解析以及卡顿问题的处理
- centos7部署k8s多master高可用集群(k8s/containerd/nginx/keepalived)
- k8s部署ingress-nginx
- docker部署keepalived非抢占单播模式
- docker-compose部署nginx反向代理tomcat
- docker-compose编排lnmp(nginx+php+mysql)环境
评论列表