--- - name: "(Install: Linux) Check For Build Tools" block: - name: "(Install: Centos/RHEL) Install Python" yum: name: - python3 - python3-pip - python3-devel update_cache: true when: ansible_os_family == "RedHat" - name: "(Install: Centos/RHEL) Set Python3 Default" alternatives: name: python path: /usr/bin/python3 link: /usr/bin/python when: - ansible_os_family == "RedHat" - ansible_distribution_major_version == "8" - name: "(Install: Centos/RHEL) Install Build Tools" yum: name: - "@Development tools" - gcc - glibc - glibc-common - gd - gd-devel - perl-core - wget - ca-certificates - zlib-devel update_cache: true when: ansible_os_family == "RedHat" - name: "(Install: Debian) Install Backports Repo For Buster" apt_repository: repo: deb http://ftp.us.debian.org/debian buster-backports main when: ansible_distribution_release == "buster" - name: "(Install: Debian/Ubuntu) Install Build Tools" apt: name: - python3-minimal - build-essential - perl - tar - checkinstall - zlib1g-dev - libtemplate-perl update_cache: true when: ansible_os_family == "Debian" - name: "(Install: Alpine) Install Build Tools" apk: name: - python - alpine-sdk - build-base - git - wget - perl - linux-headers - tar - openrc update_cache: true when: ansible_os_family == "Alpine" - name: "(Install: Alpine) Enable openrc" copy: content: "" dest: /run/openrc/softlevel force: no owner: root mode: 0644 when: ansible_os_family == "Alpine" when: nginx_install_source_build_tools - name: "(Install: Linux) Check For Source Installs" block: - name: "(Install: Linux) Check For PCRE Install" stat: path: /tmp/{{ pcre_version }} register: pcre_result - name: "(Install: Linux) Check For zlib Install" stat: path: /tmp/{{ zlib_version }} register: zlib_result - name: "(Install: Linux) Check For openssl Install" stat: path: /tmp/{{ openssl_version }} register: openssl_result - name: "(Install: Centos/RHEL) Install PCRE Dependency From Package" yum: name: pcre-devel update_cache: true when: - nginx_install_source_pcre - ansible_os_family == "RedHat" - name: "(Install: Debian/Ubuntu) Install PCRE Dependency From Package" apt: name: libpcre3-dev update_cache: true when: - nginx_install_source_pcre - ansible_os_family == "Debian" - name: "(Install: Alpine) Install PCRE Dependency From Package" apk: name: pcre-dev update_cache: true when: - nginx_install_source_pcre - ansible_os_family == "Alpine" - name: "(Install: Linux) Install PCRE Dependence From Source" block: - name: "(Install: Linux) Download PCRE Dependency" get_url: url: "http://ftp.pcre.org/pub/pcre/{{ pcre_version }}.tar.gz" dest: "/tmp/{{ pcre_version }}.tar.gz" register: pcre_source - name: "(Install: Linux) Unpack PCRE Dependency" unarchive: copy: no dest: /tmp/ src: "{{ pcre_source.dest }}" register: pcre_source_unpack - name: "(Install: Linux) Configure PCRE Dependency" command: "./configure" args: chdir: "/tmp/{{ pcre_version }}" register: pcre_configure - name: "(Install: Linux) Make PCRE Dependency" make: chdir: "/tmp/{{ pcre_version }}" - name: "(Install: Linux) Install PCRE Dependency" make: chdir: "/tmp/{{ pcre_version }}" target: install when: - not pcre_result.stat.exists - not nginx_install_source_pcre - name: "(Install: Centos/RHEL) Install zlib Dependency From Package" yum: name: zlib-devel update_cache: true when: - nginx_install_source_zlib - ansible_os_family == "RedHat" - name: "(Install: Debian/Ubuntu) Install zlib Dependency From Package" apt: name: zlib1g-dev update_cache: true when: - nginx_install_source_zlib - ansible_os_family == "Debian" - name: "(Install: Alpine) Install zlib Dependency From Package" apk: name: zlib-dev update_cache: true when: - nginx_install_source_zlib - ansible_os_family == "Alpine" - name: "(Install: Linux) Install zlib Dependency From Source" block: - name: "(Install: Linux) Download zlib Dependency" get_url: url: "http://zlib.net/{{ zlib_version }}.tar.gz" dest: "/tmp/{{ zlib_version }}.tar.gz" register: zlib_source - name: "(Install: Linux) Unpack zlib Dependency" unarchive: copy: no dest: /tmp/ src: "{{ zlib_source.dest }}" register: zlib_source_unpack - name: "(Install: Linux) Configure zlib Dependency" command: "./configure" args: chdir: "/tmp/{{ zlib_version }}" register: zlib_configure - name: "(Install: Linux) Make zlib Dependency" make: chdir: "/tmp/{{ zlib_version }}" - name: "(Install: Linux) Install zlib Dependency" make: chdir: "/tmp/{{ zlib_version }}" target: install when: - not zlib_result.stat.exists - not nginx_install_source_zlib - name: "(Install: Centos/RHEL) Install OpenSSL Dependency From Package" yum: name: openssl-devel update_cache: true when: - nginx_install_source_openssl - ansible_os_family == "RedHat" - name: "(Install: Debian/Ubuntu) Install OpenSSL Dependency From Package" apt: name: libssl-dev update_cache: true when: - nginx_install_source_openssl - ansible_os_family == "Debian" - name: "(Install: Alpine) Install OpenSSL Dependency From Package" apk: name: openssl-dev update_cache: true when: - nginx_install_source_openssl - ansible_os_family == "Alpine" - name: "(Install: Linux) Install OpenSSL Dependency From Source" block: - name: "(Install: Linux) Download OpenSSL Dependency" get_url: url: "http://www.openssl.org/source/{{ openssl_version }}.tar.gz" dest: "/tmp/{{ openssl_version }}.tar.gz" register: openssl_source - name: "(Install: Linux) Unpack OpenSSL Dependency" unarchive: copy: no dest: /tmp/ src: "{{ openssl_source.dest }}" register: openssl_source_unpack - name: "(Install: Linux) Configure OpenSSL Dependency" command: "./config --prefix=/usr" args: chdir: "/tmp/{{ openssl_version }}" register: openssl_configure - name: "(Install: Linux) Make OpenSSL Dependency" make: chdir: "/tmp/{{ openssl_version }}" - name: "(Install: Linux) Install OpenSSL Dependency" make: chdir: "/tmp/{{ openssl_version }}" target: install when: - not openssl_result.stat.exists - not nginx_install_source_openssl - name: "(Install: Linux) Get NGINX Version" block: - name: "(Install: Linux) Fetch NGINX Version" uri: url: https://trac.nginx.org/nginx/browser return_content: true register: nginx_versions - name: "(Install: Linux) Set NGINX Mainline Version" set_fact: nginx_version: "{{ nginx_versions.content | regex_search('release[^<]*') | regex_replace('release', 'nginx') }}" when: nginx_branch == "mainline" - name: "(Install: Linux) Set NGINX Stable Version 1/2" set_fact: nginx_version: "{{ nginx_versions.content | regex_search('stable[^<]*') | regex_replace('stable', 'release') }}" when: nginx_branch == "stable" - name: "(Install: Linux) Set NGINX Stable Version 2/2" set_fact: nginx_version: "{{ nginx_versions.content | regex_search(nginx_version + '[^<]*') | regex_replace('release', 'nginx') }}" when: nginx_branch == "stable" - name: "(Install: Linux) Set NGINX Download Filename" set_fact: nginx_download_name: "{{ nginx_version }}" - name: "(Install: Linux) Check For NGINX Install" stat: path: /usr/sbin/nginx follow: true register: nginx_result - name: "(Install: Linux) Add NGINX User" user: name: nginx - name: "(Install: Linux) Install NGINX" block: - name: "(Install: Linux) Download NGINX" get_url: url: "http://nginx.org/download/{{ nginx_download_name }}.tar.gz" dest: "/tmp/{{ nginx_download_name }}.tar.gz" register: nginx_source - name: "(Install: Linux) Unpack NGINX" unarchive: copy: no dest: /tmp/ src: "{{ nginx_source.dest }}" register: nginx_source_unpack - name: "(Install: Linux) Configure NGINX" command: >- ./configure --prefix=/usr --pid-path=/var/run/nginx.pid --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 --with-http_ssl_module --with-stream --with-mail=dynamic {{ 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 - name: "(Install: Linux) Make NGINX" make: chdir: "/tmp/{{ nginx_version }}" - name: "(Install: Linux) Install NGINX" make: chdir: "/tmp/{{ nginx_version }}" target: install - name: "(Install: Linux) Upload systemd NGINX Service File" copy: src: services/nginx.systemd dest: /lib/systemd/system/nginx.service owner: root group: root mode: '0644' when: ansible_service_mgr == "systemd" - name: "(Install: Linux) Enable systemd NGINX Service File" systemd: daemon_reload: yes name: nginx state: restarted enabled: yes notify: "(Handler: All OSs) Start NGINX" when: ansible_service_mgr == "systemd" - name: "(Install: Linux) Upload upstart NGINX Service File" copy: src: services/nginx.upstart dest: /etc/init.d/nginx owner: root group: root mode: '0755' when: ansible_service_mgr == "upstart" - name: "(Install: Linux) Upload upstart NGINX Service Conf File" copy: src: services/nginx.conf.upstart dest: /etc/init/nginx.conf owner: root group: root mode: '0644' when: ansible_service_mgr == "upstart" - name: "(Install: Linux) Enable upstart NGINX Service Reload" command: "initctl reload-configuration" when: ansible_service_mgr == "upstart" - name: "(Install: Linux) Start upstart NGINX Service Reload" command: "nginx" notify: "(Handler: All OSs) Start NGINX" when: ansible_service_mgr == "upstart" - name: "(Install: Linux) Upload sysvinit NGINX Service File" copy: src: services/nginx.sysvinit dest: /etc/init.d/nginx owner: root group: root mode: '0755' notify: "(Handler: All OSs) Start NGINX" when: ansible_service_mgr == "sysvinit" - name: "(Install: Linux) Upload openrc NGINX Service File" copy: src: services/nginx.openrc dest: /etc/init.d/nginx owner: root group: root mode: '0755' when: ansible_service_mgr == "openrc" - name: "(Install: Linux) Enable openrc NGINX Service" command: rc-update add nginx default notify: "(Handler: All OSs) Start NGINX" when: ansible_service_mgr == "openrc" when: not nginx_result.stat.exists - name: "(Install: Linux) Cleanup Downloads" file: path: "{{ item }}" state: absent loop: - "{{ pcre_source.dest }}" - "{{ zlib_source.dest }}" - "{{ openssl_source.dest }}" - "{{ nginx_source.dest }}" when: item is defined