2020-03-25 18:43:32 +01:00
|
|
|
---
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Check for build tools"
|
2020-03-25 18:43:32 +01:00
|
|
|
block:
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "(CentOS/RHEL 8) Setup Python 3"
|
2020-08-28 10:30:23 +02:00
|
|
|
block:
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "(CentOS/RHEL 8) Install Python 3"
|
2020-08-28 10:30:23 +02:00
|
|
|
yum:
|
|
|
|
name:
|
|
|
|
- python3
|
|
|
|
- python3-pip
|
|
|
|
- python3-devel
|
|
|
|
update_cache: yes
|
|
|
|
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "(Centos/RHEL 8) Set Python 3 as default"
|
2020-08-28 10:30:23 +02:00
|
|
|
alternatives:
|
|
|
|
name: python
|
|
|
|
path: /usr/bin/python3
|
|
|
|
link: /usr/bin/python
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "RedHat"
|
|
|
|
- ansible_facts['distribution_major_version'] is version('8', '==')
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Centos/RHEL) Install build tools"
|
2020-07-27 13:19:12 +02:00
|
|
|
yum:
|
2020-03-25 18:43:32 +01:00
|
|
|
name:
|
|
|
|
- "@Development tools"
|
2020-09-15 21:27:06 +02:00
|
|
|
- ca-certificates
|
2020-03-25 18:43:32 +01:00
|
|
|
- gcc
|
|
|
|
- gd
|
|
|
|
- gd-devel
|
2020-09-15 21:27:06 +02:00
|
|
|
- glibc
|
|
|
|
- glibc-common
|
2020-03-25 18:43:32 +01:00
|
|
|
- perl-core
|
|
|
|
- wget
|
|
|
|
- zlib-devel
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['os_family'] == "RedHat"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "(Debian) Install backports repo for 'buster'"
|
2020-03-25 18:43:32 +01:00
|
|
|
apt_repository:
|
2020-08-28 10:30:23 +02:00
|
|
|
filename: buster-backports
|
2020-03-25 18:43:32 +01:00
|
|
|
repo: deb http://ftp.us.debian.org/debian buster-backports main
|
2020-08-28 10:30:23 +02:00
|
|
|
update_cache: yes
|
|
|
|
mode: 0644
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['distribution_release'] == "buster"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Debian/Ubuntu) Install build tools"
|
2020-07-27 13:19:12 +02:00
|
|
|
apt:
|
2020-03-25 18:43:32 +01:00
|
|
|
name:
|
|
|
|
- build-essential
|
2020-09-15 21:27:06 +02:00
|
|
|
- checkinstall
|
|
|
|
- libtemplate-perl
|
|
|
|
- python3-minimal
|
2020-03-25 18:43:32 +01:00
|
|
|
- perl
|
|
|
|
- tar
|
|
|
|
- zlib1g-dev
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['os_family'] == "Debian"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Alpine Linux) Install build tools"
|
2020-07-27 13:19:12 +02:00
|
|
|
apk:
|
2020-03-25 18:43:32 +01:00
|
|
|
name:
|
|
|
|
- alpine-sdk
|
|
|
|
- build-base
|
|
|
|
- git
|
2020-09-15 21:27:06 +02:00
|
|
|
- openrc
|
2020-03-25 18:43:32 +01:00
|
|
|
- perl
|
2020-09-15 21:27:06 +02:00
|
|
|
- python3
|
2020-03-25 18:43:32 +01:00
|
|
|
- linux-headers
|
|
|
|
- tar
|
2020-09-15 21:27:06 +02:00
|
|
|
- wget
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['os_family'] == "Alpine"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Alpine Linux) Enable OpenRC"
|
2020-03-25 18:43:32 +01:00
|
|
|
copy:
|
|
|
|
content: ""
|
|
|
|
dest: /run/openrc/softlevel
|
|
|
|
force: no
|
|
|
|
owner: root
|
|
|
|
mode: 0644
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['os_family'] == "Alpine"
|
2020-08-28 10:30:23 +02:00
|
|
|
when: nginx_install_source_build_tools | bool
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Check for source installs"
|
2020-03-25 18:43:32 +01:00
|
|
|
block:
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Check for PCRE install"
|
2020-03-25 18:43:32 +01:00
|
|
|
stat:
|
|
|
|
path: /tmp/{{ pcre_version }}
|
|
|
|
register: pcre_result
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Check for ZLib install"
|
2020-03-25 18:43:32 +01:00
|
|
|
stat:
|
|
|
|
path: /tmp/{{ zlib_version }}
|
|
|
|
register: zlib_result
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Check for OpenSSL install"
|
2020-03-25 18:43:32 +01:00
|
|
|
stat:
|
|
|
|
path: /tmp/{{ openssl_version }}
|
|
|
|
register: openssl_result
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(CentOS/RHEL) Install PCRE dependency from package"
|
2020-07-27 13:19:12 +02:00
|
|
|
yum:
|
2020-03-25 18:43:32 +01:00
|
|
|
name: pcre-devel
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- nginx_install_source_pcre | bool
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "RedHat"
|
2020-07-27 13:19:12 +02:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Debian/Ubuntu) Install PCRE dependency from package"
|
2020-07-27 13:19:12 +02:00
|
|
|
apt:
|
|
|
|
name: libpcre3-dev
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- nginx_install_source_pcre | bool
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "Debian"
|
2020-07-27 13:19:12 +02:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Alpine Linux) Install PCRE dependency from package"
|
2020-07-27 13:19:12 +02:00
|
|
|
apk:
|
2020-03-25 18:43:32 +01:00
|
|
|
name: pcre-dev
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- nginx_install_source_pcre | bool
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "Alpine"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Install PCRE dependence from source"
|
2020-03-25 18:43:32 +01:00
|
|
|
block:
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Download PCRE dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
get_url:
|
2020-09-15 21:27:06 +02:00
|
|
|
url: "https://ftp.pcre.org/pub/pcre/{{ pcre_version }}.tar.gz"
|
2020-03-25 18:43:32 +01:00
|
|
|
dest: "/tmp/{{ pcre_version }}.tar.gz"
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0600
|
2020-09-18 15:09:59 +02:00
|
|
|
validate_certs: "{{ (ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] is version('6', '=='))
|
|
|
|
| ternary('no', 'yes') }}"
|
2020-03-25 18:43:32 +01:00
|
|
|
register: pcre_source
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Unpack PCRE dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
unarchive:
|
|
|
|
copy: no
|
|
|
|
dest: /tmp/
|
|
|
|
src: "{{ pcre_source.dest }}"
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0700
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Configure PCRE dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
command: "./configure"
|
|
|
|
args:
|
|
|
|
chdir: "/tmp/{{ pcre_version }}"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Make PCRE dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
make:
|
|
|
|
chdir: "/tmp/{{ pcre_version }}"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Install PCRE dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
make:
|
|
|
|
chdir: "/tmp/{{ pcre_version }}"
|
|
|
|
target: install
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- not pcre_result.stat.exists | bool
|
|
|
|
- not nginx_install_source_pcre | bool
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Centos/RHEL) Install ZLib dependency from package"
|
2020-07-27 13:19:12 +02:00
|
|
|
yum:
|
2020-03-25 18:43:32 +01:00
|
|
|
name: zlib-devel
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- nginx_install_source_zlib | bool
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "RedHat"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Debian/Ubuntu) Install ZLib dependency from package"
|
2020-07-27 13:19:12 +02:00
|
|
|
apt:
|
2020-03-25 18:43:32 +01:00
|
|
|
name: zlib1g-dev
|
2020-07-27 13:19:12 +02:00
|
|
|
update_cache: true
|
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- nginx_install_source_zlib | bool
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "Debian"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Alpine Linux) Install ZLib dependency from package"
|
2020-07-27 13:19:12 +02:00
|
|
|
apk:
|
2020-03-25 18:43:32 +01:00
|
|
|
name: zlib-dev
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- nginx_install_source_zlib | bool
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "Alpine"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Install ZLib dependency from source"
|
2020-03-25 18:43:32 +01:00
|
|
|
block:
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Download ZLib dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
get_url:
|
2020-09-15 21:27:06 +02:00
|
|
|
url: "https://zlib.net/{{ zlib_version }}.tar.gz"
|
2020-03-25 18:43:32 +01:00
|
|
|
dest: "/tmp/{{ zlib_version }}.tar.gz"
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0600
|
2020-09-18 15:09:59 +02:00
|
|
|
validate_certs: "{{ (ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] is version('6', '=='))
|
|
|
|
| ternary('no', 'yes') }}"
|
2020-03-25 18:43:32 +01:00
|
|
|
register: zlib_source
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Unpack ZLib dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
unarchive:
|
|
|
|
copy: no
|
|
|
|
dest: /tmp/
|
|
|
|
src: "{{ zlib_source.dest }}"
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0700
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Configure ZLib dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
command: "./configure"
|
|
|
|
args:
|
|
|
|
chdir: "/tmp/{{ zlib_version }}"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Make ZLib dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
make:
|
|
|
|
chdir: "/tmp/{{ zlib_version }}"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Install ZLib dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
make:
|
|
|
|
chdir: "/tmp/{{ zlib_version }}"
|
|
|
|
target: install
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- not zlib_result.stat.exists | bool
|
|
|
|
- not nginx_install_source_zlib | bool
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(CentOS/RHEL) Install OpenSSL dependency from package"
|
2020-07-27 13:19:12 +02:00
|
|
|
yum:
|
2020-03-25 18:43:32 +01:00
|
|
|
name: openssl-devel
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- nginx_install_source_openssl | bool
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "RedHat"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Debian/Ubuntu) Install OpenSSL dependency from package"
|
2020-07-27 13:19:12 +02:00
|
|
|
apt:
|
2020-03-25 18:43:32 +01:00
|
|
|
name: libssl-dev
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- nginx_install_source_openssl | bool
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "Debian"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "(Alpine Linux) Install OpenSSL dependency from package"
|
2020-07-27 13:19:12 +02:00
|
|
|
apk:
|
2020-03-25 18:43:32 +01:00
|
|
|
name: openssl-dev
|
2020-07-30 12:47:08 +02:00
|
|
|
update_cache: yes
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- nginx_install_source_openssl | bool
|
2020-09-15 21:27:06 +02:00
|
|
|
- ansible_facts['os_family'] == "Alpine"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Install OpenSSL dependency from source"
|
2020-03-25 18:43:32 +01:00
|
|
|
block:
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Download OpenSSL dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
get_url:
|
2020-09-15 21:27:06 +02:00
|
|
|
url: "https://www.openssl.org/source/{{ openssl_version }}.tar.gz"
|
2020-03-25 18:43:32 +01:00
|
|
|
dest: "/tmp/{{ openssl_version }}.tar.gz"
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0600
|
2020-09-18 15:09:59 +02:00
|
|
|
validate_certs: "{{ (ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] is version('6', '=='))
|
|
|
|
| ternary('no', 'yes') }}"
|
2020-03-25 18:43:32 +01:00
|
|
|
register: openssl_source
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Unpack OpenSSL dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
unarchive:
|
|
|
|
copy: no
|
|
|
|
dest: /tmp/
|
|
|
|
src: "{{ openssl_source.dest }}"
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0700
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Configure OpenSSL dependency"
|
2020-08-28 10:30:23 +02:00
|
|
|
command: "./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib"
|
2020-03-25 18:43:32 +01:00
|
|
|
args:
|
|
|
|
chdir: "/tmp/{{ openssl_version }}"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Make OpenSSL dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
make:
|
|
|
|
chdir: "/tmp/{{ openssl_version }}"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Install OpenSSL dependency"
|
2020-03-25 18:43:32 +01:00
|
|
|
make:
|
|
|
|
chdir: "/tmp/{{ openssl_version }}"
|
|
|
|
target: install
|
2020-07-27 13:19:12 +02:00
|
|
|
when:
|
2020-08-28 10:30:23 +02:00
|
|
|
- not openssl_result.stat.exists | bool
|
|
|
|
- not nginx_install_source_openssl | bool
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Get NGINX version"
|
2020-03-25 18:43:32 +01:00
|
|
|
block:
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Fetch NGINX version"
|
2020-07-27 13:19:12 +02:00
|
|
|
uri:
|
|
|
|
url: https://trac.nginx.org/nginx/browser
|
2020-07-30 12:47:08 +02:00
|
|
|
return_content: yes
|
2020-09-18 15:09:59 +02:00
|
|
|
validate_certs: "{{ (ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] is version('6', '=='))
|
|
|
|
| ternary('no', 'yes') }}"
|
2020-07-27 13:19:12 +02:00
|
|
|
register: nginx_versions
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Set NGINX mainline version"
|
2020-03-25 18:43:32 +01:00
|
|
|
set_fact:
|
2020-07-27 13:19:12 +02:00
|
|
|
nginx_version: "{{ nginx_versions.content | regex_search('release[^<]*') | regex_replace('release', 'nginx') }}"
|
2020-03-25 18:43:32 +01:00
|
|
|
when: nginx_branch == "mainline"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Set NGINX stable version 1/2"
|
2020-07-27 13:19:12 +02:00
|
|
|
set_fact:
|
|
|
|
nginx_version: "{{ nginx_versions.content | regex_search('stable[^<]*') | regex_replace('stable', 'release') }}"
|
2020-03-25 18:43:32 +01:00
|
|
|
when: nginx_branch == "stable"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Set NGINX stable version 2/2"
|
2020-03-25 18:43:32 +01:00
|
|
|
set_fact:
|
2020-07-27 13:19:12 +02:00
|
|
|
nginx_version: "{{ nginx_versions.content | regex_search(nginx_version + '[^<]*') | regex_replace('release', 'nginx') }}"
|
2020-03-25 18:43:32 +01:00
|
|
|
when: nginx_branch == "stable"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Set NGINX download filename"
|
2020-03-25 18:43:32 +01:00
|
|
|
set_fact:
|
|
|
|
nginx_download_name: "{{ nginx_version }}"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Check for NGINX install"
|
2020-03-25 18:43:32 +01:00
|
|
|
stat:
|
|
|
|
path: /usr/sbin/nginx
|
2020-07-30 12:47:08 +02:00
|
|
|
follow: yes
|
2020-03-25 18:43:32 +01:00
|
|
|
register: nginx_result
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Add NGINX user"
|
2020-03-25 18:43:32 +01:00
|
|
|
user:
|
|
|
|
name: nginx
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Install NGINX"
|
2020-03-25 18:43:32 +01:00
|
|
|
block:
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Download NGINX"
|
2020-03-25 18:43:32 +01:00
|
|
|
get_url:
|
2020-09-15 21:27:06 +02:00
|
|
|
url: "https://nginx.org/download/{{ nginx_download_name }}.tar.gz"
|
2020-03-25 18:43:32 +01:00
|
|
|
dest: "/tmp/{{ nginx_download_name }}.tar.gz"
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0600
|
2020-09-18 15:09:59 +02:00
|
|
|
validate_certs: "{{ (ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] is version('6', '=='))
|
|
|
|
| ternary('no', 'yes') }}"
|
2020-03-25 18:43:32 +01:00
|
|
|
register: nginx_source
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Unpack NGINX"
|
2020-03-25 18:43:32 +01:00
|
|
|
unarchive:
|
|
|
|
copy: no
|
|
|
|
dest: /tmp/
|
|
|
|
src: "{{ nginx_source.dest }}"
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0755
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Configure NGINX"
|
2020-03-25 18:43:32 +01:00
|
|
|
command: >-
|
|
|
|
./configure
|
|
|
|
--conf-path=/etc/nginx/nginx.conf
|
|
|
|
--error-log-path=/var/log/nginx/error.log
|
|
|
|
--http-log-path=/var/log/nginx/access.log
|
|
|
|
--lock-path=/var/lock/nginx.lock
|
|
|
|
--modules-path=/usr/lib/nginx/modules
|
2020-09-15 21:27:06 +02:00
|
|
|
--prefix=/usr
|
|
|
|
--pid-path=/var/run/nginx.pid
|
2020-03-25 18:43:32 +01:00
|
|
|
--with-http_ssl_module
|
|
|
|
--with-mail=dynamic
|
2020-09-15 21:27:06 +02:00
|
|
|
--with-stream
|
2020-03-25 18:43:32 +01:00
|
|
|
{{ nginx_install_source_pcre | ternary('', '--with-pcre=../' + pcre_version) }}
|
|
|
|
{{ nginx_install_source_zlib | ternary('', '--with-zlib=../' + zlib_version) }}
|
|
|
|
{{ nginx_install_source_openssl | ternary('', '--with-openssl=../' + openssl_version) }}
|
|
|
|
args:
|
|
|
|
chdir: "/tmp/{{ nginx_version }}"
|
|
|
|
register: nginx_configure
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Make NGINX"
|
2020-03-25 18:43:32 +01:00
|
|
|
make:
|
|
|
|
chdir: "/tmp/{{ nginx_version }}"
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Install NGINX"
|
2020-03-25 18:43:32 +01:00
|
|
|
make:
|
|
|
|
chdir: "/tmp/{{ nginx_version }}"
|
|
|
|
target: install
|
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Upload systemd NGINX service file"
|
2020-03-25 18:43:32 +01:00
|
|
|
copy:
|
|
|
|
src: services/nginx.systemd
|
|
|
|
dest: /lib/systemd/system/nginx.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0644
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['service_mgr'] == "systemd"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Enable systemd NGINX service file"
|
2020-03-25 18:43:32 +01:00
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: nginx
|
|
|
|
state: restarted
|
|
|
|
enabled: yes
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['service_mgr'] == "systemd"
|
2020-09-17 17:00:27 +02:00
|
|
|
notify: "(Handler) Run NGINX"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Upload upstart NGINX service file"
|
2020-03-25 18:43:32 +01:00
|
|
|
copy:
|
|
|
|
src: services/nginx.upstart
|
|
|
|
dest: /etc/init.d/nginx
|
|
|
|
owner: root
|
|
|
|
group: root
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0755
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['service_mgr'] == "upstart"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "Upload Upstart NGINX service conf file"
|
2020-03-25 18:43:32 +01:00
|
|
|
copy:
|
|
|
|
src: services/nginx.conf.upstart
|
|
|
|
dest: /etc/init/nginx.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0644
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['service_mgr'] == "upstart"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "Enable Upstart NGINX service reload"
|
2020-03-25 18:43:32 +01:00
|
|
|
command: "initctl reload-configuration"
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['service_mgr'] == "upstart"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "Start Upstart NGINX service reload"
|
2020-03-25 18:43:32 +01:00
|
|
|
command: "nginx"
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['service_mgr'] == "upstart"
|
2020-09-17 17:00:27 +02:00
|
|
|
notify: "(Handler) Run NGINX"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "Upload SysVinit NGINX service file"
|
2020-03-25 18:43:32 +01:00
|
|
|
copy:
|
|
|
|
src: services/nginx.sysvinit
|
|
|
|
dest: /etc/init.d/nginx
|
|
|
|
owner: root
|
|
|
|
group: root
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0755
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['service_mgr'] == "sysvinit"
|
2020-09-17 17:00:27 +02:00
|
|
|
notify: "(Handler) Run NGINX"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "Upload OpenRC NGINX service file"
|
2020-03-25 18:43:32 +01:00
|
|
|
copy:
|
|
|
|
src: services/nginx.openrc
|
|
|
|
dest: /etc/init.d/nginx
|
|
|
|
owner: root
|
|
|
|
group: root
|
2020-08-28 10:30:23 +02:00
|
|
|
mode: 0755
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['service_mgr'] == "openrc"
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-16 18:58:32 +02:00
|
|
|
- name: "Enable OpenRC NGINX service"
|
2020-03-25 18:43:32 +01:00
|
|
|
command: rc-update add nginx default
|
2020-09-15 21:27:06 +02:00
|
|
|
when: ansible_facts['service_mgr'] == "openrc"
|
2020-09-17 17:00:27 +02:00
|
|
|
notify: "(Handler) Run NGINX"
|
2020-07-27 13:19:12 +02:00
|
|
|
when: not nginx_result.stat.exists
|
2020-03-25 18:43:32 +01:00
|
|
|
|
2020-09-15 21:27:06 +02:00
|
|
|
- name: "Cleanup downloads"
|
2020-03-25 18:43:32 +01:00
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- "{{ pcre_source.dest }}"
|
|
|
|
- "{{ zlib_source.dest }}"
|
|
|
|
- "{{ openssl_source.dest }}"
|
|
|
|
- "{{ nginx_source.dest }}"
|
|
|
|
when: item is defined
|