ansible/nginx.yml
2021-03-31 22:05:22 -04:00

110 lines
3.1 KiB
YAML

# Copyright 2021, Edward Kujawski
# https://gitea.atl.org/ekujawski/ansible
# Licenced under the GPL-3 of later license.
# https://gitea.atl.org/ekujawski/ansible/src/branch/master/LICENSE
- name: Install NginX
hosts: application_servers
vars:
nginx_version: 1.19.8
nginx_dev_version: 0.3.1
openssl_version: 1.1.1k
tasks:
- name: RPM dependencies
dnf:
name:
- git
- gcc
- brotli-devel
- pcre-devel
- zlib-devel
- perl-FindBin
- perl-File-Compare
- name: OpenSSL Downloaded
stat:
path: /usr/local/src/openssl-{{ openssl_version }}.tar.gz
register: openssl_downloaded
- name: Download OpenSSL
shell: |
cd /usr/local/src
wget https://www.openssl.org/source/openssl-{{ openssl_version }}.tar.gz
when: openssl_downloaded.stat.exists == False
- name: Extract OpenSSL
shell: |
cd /usr/local/src
rm -rf openssl-{{ openssl_version }}
tar -xzf openssl-{{ openssl_version }}.tar.gz
- name: Download NGINX Dev Kit
shell: |
cd /usr/local/src
if [ ! -f ngx_devel_kit-{{ nginx_dev_version }}.tar.gz ] ; then
wget https://github.com/vision5/ngx_devel_kit/archive/refs/tags/v{{ nginx_dev_version }}.tar.gz -O ngx_devel_kit-{{ nginx_dev_version }}.tar.gz
fi
if [ ! -d ngx_devel_kit-{{ nginx_dev_version }} ] ; then
tar -xzf ngx_devel_kit-{{ nginx_dev_version }}.tar.gz
fi
rm -f ngx_devel_kit
ln -s ngx_devel_kit-{{ nginx_dev_version }} ngx_devel_kit
- name: NGINX Brotli
shell: |
cd /usr/local/src
if [ ! -d ngx_brotli ] ; then
git clone https://github.com/google/ngx_brotli.git
fi
cd ngx_brotli
git pull
- name: NGINX Downloaded
stat:
path: /usr/local/src/nginx-{{ nginx_version }}.tar.gz
register: nginx_downloaded
- name: Download NGINX
shell: |
cd /usr/local/src
wget https://nginx.org/download/nginx-{{ nginx_version }}.tar.gz
when: nginx_downloaded.stat.exists == False
- name: NGINX Configure
shell: |
cd /usr/local/src
cat > nginx-{{ nginx_version }}.configure <<EOF
./configure --prefix='/usr/local/nginx-{{ nginx_version }}' \
--with-http_ssl_module \
--with-mail \
--with-mail_ssl_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-cc-opt='-Wno-error' \
--with-http_v2_module \
--with-ld-opt='-Wl,-rpath,/usr/lib64' \
--add-module=/usr/local/src/ngx_devel_kit \
--add-module=/usr/local/src/ngx_brotli \
--with-openssl=/usr/local/src/openssl-1.1.1k \
--with-http_auth_request_module \
--with-stream
EOF
- name: NGINX Code
shell: |
cd /usr/local/src
rm -rf nginx-{{ nginx_version }}
tar -xzf nginx-{{ nginx_version }}.tar.gz
- name: NGINX Compile
shell: |
cd /usr/local/src/nginx-{{ nginx_version }}
. ../nginx-{{ nginx_version }}.configure
make -j2 install
cd /usr/local
rm -rf nginx
ln -s nginx-{{ nginx_version }} nginx