Cleanup source install and remove shell module tasks (#290)

This commit is contained in:
Alessandro Fael Garcia 2020-07-27 13:19:12 +02:00 committed by GitHub
parent 2fdb426e6c
commit 36b42e563a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 141 additions and 135 deletions

View File

@ -7,8 +7,8 @@
nginx_debug_output: true nginx_debug_output: true
nginx_install_from: source nginx_install_from: source
nginx_branch: mainline nginx_branch: stable
nginx_install_source_build_tools: true nginx_install_source_build_tools: true
nginx_install_source_pcre: false nginx_install_source_pcre: true
nginx_install_source_openssl: true nginx_install_source_openssl: true
nginx_install_source_zlib: false nginx_install_source_zlib: true

View File

@ -1,26 +1,26 @@
--- ---
- name: "(Install: Linux) Check for build tools" - name: "(Install: Linux) Check For Build Tools"
when: nginx_install_source_build_tools
block: block:
- name: "(Install: Centos/RHEL) Install Python"
- name: "(Install: Linux) Install Python - Centos/RHEL" yum:
package:
name: name:
- python3 - python3
- python3-pip - python3-pip
- python3-devel - python3-devel
state: present update_cache: true
when: ansible_os_family == "RedHat" when: ansible_os_family == "RedHat"
- name: "(Install: Linux) Set Python3 default - Centos/RHEL" - name: "(Install: Centos/RHEL) Set Python3 Default"
alternatives: alternatives:
name: python name: python
path: /usr/bin/python3 path: /usr/bin/python3
link: /usr/bin/python link: /usr/bin/python
when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "8" when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version == "8"
- name: "(Install: Linux) Install Build Tools - Centos/RHEL" - name: "(Install: Centos/RHEL) Install Build Tools"
package: yum:
name: name:
- "@Development tools" - "@Development tools"
- gcc - gcc
@ -32,16 +32,16 @@
- wget - wget
- ca-certificates - ca-certificates
- zlib-devel - zlib-devel
state: present update_cache: true
when: ansible_os_family == "RedHat" when: ansible_os_family == "RedHat"
- name: "(Install: Linux) Install backports repo for Buster" - name: "(Install: Debian) Install Backports Repo For Buster"
apt_repository: apt_repository:
repo: deb http://ftp.us.debian.org/debian buster-backports main repo: deb http://ftp.us.debian.org/debian buster-backports main
when: ansible_distribution_release == "buster" when: ansible_distribution_release == "buster"
- name: "(Install: Linux) Install Build Tools - Debian/Ubuntu" - name: "(Install: Debian/Ubuntu) Install Build Tools"
package: apt:
name: name:
- python3-minimal - python3-minimal
- build-essential - build-essential
@ -50,11 +50,11 @@
- checkinstall - checkinstall
- zlib1g-dev - zlib1g-dev
- libtemplate-perl - libtemplate-perl
state: present update_cache: true
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
- name: "(Install: Linux) Install Build Tools - Alpine" - name: "(Install: Alpine) Install Build Tools"
package: apk:
name: name:
- python - python
- alpine-sdk - alpine-sdk
@ -65,10 +65,10 @@
- linux-headers - linux-headers
- tar - tar
- openrc - openrc
state: present update_cache: true
when: ansible_os_family == "Alpine" when: ansible_os_family == "Alpine"
- name: "(Install: Linux) Enable openrc - Alpine" - name: "(Install: Alpine) Enable openrc"
copy: copy:
content: "" content: ""
dest: /run/openrc/softlevel dest: /run/openrc/softlevel
@ -76,218 +76,224 @@
owner: root owner: root
mode: 0644 mode: 0644
when: ansible_os_family == "Alpine" when: ansible_os_family == "Alpine"
when: nginx_install_source_build_tools
- name: "(Install: Linux) Check for Source Installs" - name: "(Install: Linux) Check For Source Installs"
block: block:
- name: "(Install: Linux) Check For PCRE Install"
- name: "(Install: Linux) Check for PCRE Install"
stat: stat:
path: /tmp/{{ pcre_version }} path: /tmp/{{ pcre_version }}
register: pcre_result register: pcre_result
- name: "(Install: Linux) Check for zlib Install" - name: "(Install: Linux) Check For zlib Install"
stat: stat:
path: /tmp/{{ zlib_version }} path: /tmp/{{ zlib_version }}
register: zlib_result register: zlib_result
- name: "(Install: Linux) Check for openssl Install" - name: "(Install: Linux) Check For openssl Install"
stat: stat:
path: /tmp/{{ openssl_version }} path: /tmp/{{ openssl_version }}
register: openssl_result register: openssl_result
- name: "(Install: Linux) Install PCRE Dependency: Package: Centos/RHEL" - name: "(Install: Centos/RHEL) Install PCRE Dependency From Package"
when: nginx_install_source_pcre and ansible_os_family == "RedHat" yum:
package:
name: pcre-devel name: pcre-devel
state: present update_cache: true
when:
- nginx_install_source_pcre
- ansible_os_family == "RedHat"
- name: "(Install: Linux) Install PCRE Dependency: Package: Debian/Ubuntu" - name: "(Install: Debian/Ubuntu) Install PCRE Dependency From Package"
when: nginx_install_source_pcre and ansible_os_family == "Debian" apt:
package: name: libpcre3-dev
name: libpcre3dev update_cache: true
state: present when:
- nginx_install_source_pcre
- ansible_os_family == "Debian"
- name: "(Install: Linux) Install PCRE Dependency: Package: Alpine" - name: "(Install: Alpine) Install PCRE Dependency From Package"
when: nginx_install_source_pcre and ansible_os_family == "Alpine" apk:
package:
name: pcre-dev name: pcre-dev
state: present update_cache: true
when:
- nginx_install_source_pcre
- ansible_os_family == "Alpine"
- name: "(Install: Linux) Install PCRE Dependency: Source" - name: "(Install: Linux) Install PCRE Dependence From Source"
when: not pcre_result.stat.exists and not nginx_install_source_pcre
block: block:
- name: "(Install: Linux) Download PCRE Dependency"
- name: "(Install: Linux) Install PCRE Dependency: Download"
get_url: get_url:
url: "http://ftp.pcre.org/pub/pcre/{{ pcre_version }}.tar.gz" url: "http://ftp.pcre.org/pub/pcre/{{ pcre_version }}.tar.gz"
dest: "/tmp/{{ pcre_version }}.tar.gz" dest: "/tmp/{{ pcre_version }}.tar.gz"
register: pcre_source register: pcre_source
- name: "(Install: Linux) Install PCRE Dependency: Unpack" - name: "(Install: Linux) Unpack PCRE Dependency"
unarchive: unarchive:
copy: no copy: no
dest: /tmp/ dest: /tmp/
src: "{{ pcre_source.dest }}" src: "{{ pcre_source.dest }}"
register: pcre_source_unpack register: pcre_source_unpack
- name: "(Install: Linux) Install PCRE Dependency: Configure" - name: "(Install: Linux) Configure PCRE Dependency"
command: "./configure" command: "./configure"
args: args:
chdir: "/tmp/{{ pcre_version }}" chdir: "/tmp/{{ pcre_version }}"
register: pcre_configure register: pcre_configure
- name: "(Install: Linux) Install PCRE Dependency: Install" - name: "(Install: Linux) Make PCRE Dependency"
make: make:
chdir: "/tmp/{{ pcre_version }}" chdir: "/tmp/{{ pcre_version }}"
- name: "(Install: Linux) Install PCRE Dependency: Install" - name: "(Install: Linux) Install PCRE Dependency"
make: make:
chdir: "/tmp/{{ pcre_version }}" chdir: "/tmp/{{ pcre_version }}"
target: install target: install
when:
- not pcre_result.stat.exists
- not nginx_install_source_pcre
- name: "(Install: Linux) Install zlib Dependency: Package: Centos/RHEL" - name: "(Install: Centos/RHEL) Install zlib Dependency From Package"
when: nginx_install_source_zlib and ansible_os_family == "RedHat" yum:
package:
name: zlib-devel name: zlib-devel
state: present update_cache: true
when:
- nginx_install_source_zlib
- ansible_os_family == "RedHat"
- name: "(Install: Linux) Install zlib Dependency: Package: Debian/Ubuntu" - name: "(Install: Debian/Ubuntu) Install zlib Dependency From Package"
when: nginx_install_source_zlib and ansible_os_family == "Debian" apt:
package:
name: zlib1g-dev name: zlib1g-dev
state: present update_cache: true
when:
- nginx_install_source_zlib
- ansible_os_family == "Debian"
- name: "(Install: Linux) Install zlib Dependency: Package: Alpine" - name: "(Install: Alpine) Install zlib Dependency From Package"
when: nginx_install_source_zlib and ansible_os_family == "Alpine" apk:
package:
name: zlib-dev name: zlib-dev
state: present update_cache: true
when:
- nginx_install_source_zlib
- ansible_os_family == "Alpine"
- name: "(Install: Linux) Install zlib Dependency: Source" - name: "(Install: Linux) Install zlib Dependency From Source"
when: not zlib_result.stat.exists and not nginx_install_source_zlib
block: block:
- name: "(Install: Linux) Download zlib Dependency"
- name: "(Install: Linux) Install zlib Dependency: Download"
get_url: get_url:
url: "http://zlib.net/{{ zlib_version }}.tar.gz" url: "http://zlib.net/{{ zlib_version }}.tar.gz"
dest: "/tmp/{{ zlib_version }}.tar.gz" dest: "/tmp/{{ zlib_version }}.tar.gz"
register: zlib_source register: zlib_source
- name: "(Install: Linux) Install zlib Dependency: Unpack" - name: "(Install: Linux) Unpack zlib Dependency"
unarchive: unarchive:
copy: no copy: no
dest: /tmp/ dest: /tmp/
src: "{{ zlib_source.dest }}" src: "{{ zlib_source.dest }}"
register: zlib_source_unpack register: zlib_source_unpack
- name: "(Install: Linux) Install zlib Dependency: Configure" - name: "(Install: Linux) Configure zlib Dependency"
command: "./configure" command: "./configure"
args: args:
chdir: "/tmp/{{ zlib_version }}" chdir: "/tmp/{{ zlib_version }}"
register: zlib_configure register: zlib_configure
- name: "(Install: Linux) Install zlib Dependency: Install" - name: "(Install: Linux) Make zlib Dependency"
make: make:
chdir: "/tmp/{{ zlib_version }}" chdir: "/tmp/{{ zlib_version }}"
- name: "(Install: Linux) Install zlib Dependency: Install" - name: "(Install: Linux) Install zlib Dependency"
make: make:
chdir: "/tmp/{{ zlib_version }}" chdir: "/tmp/{{ zlib_version }}"
target: install target: install
when:
- not zlib_result.stat.exists
- not nginx_install_source_zlib
- name: "(Install: Linux) Install OpenSSL Dependency: Package: Centos/RHEL" - name: "(Install: Centos/RHEL) Install OpenSSL Dependency From Package"
when: nginx_install_source_openssl and ansible_os_family == "RedHat" yum:
package:
name: openssl-devel name: openssl-devel
state: present update_cache: true
when:
- nginx_install_source_openssl
- ansible_os_family == "RedHat"
- name: "(Install: Linux) Install OpenSSL Dependency: Package: Debian/Ubuntu" - name: "(Install: Debian/Ubuntu) Install OpenSSL Dependency From Package"
when: nginx_install_source_openssl and ansible_os_family == "Debian" apt:
package:
name: libssl-dev name: libssl-dev
state: present update_cache: true
when:
- nginx_install_source_openssl
- ansible_os_family == "Debian"
- name: "(Install: Linux) Install OpenSSL Dependency: Package: Alpine" - name: "(Install: Alpine) Install OpenSSL Dependency From Package"
when: nginx_install_source_openssl and ansible_os_family == "Alpine" apk:
package:
name: openssl-dev name: openssl-dev
state: present update_cache: true
when:
- nginx_install_source_openssl
- ansible_os_family == "Alpine"
- name: "(Install: Linux) Install OpenSSL Dependency: Source" - name: "(Install: Linux) Install OpenSSL Dependency From Source"
when: not openssl_result.stat.exists and not nginx_install_source_openssl
block: block:
- name: "(Install: Linux) Download OpenSSL Dependency"
- name: "(Install: Linux) Install OpenSSL Dependency: Download"
get_url: get_url:
url: "http://www.openssl.org/source/{{ openssl_version }}.tar.gz" url: "http://www.openssl.org/source/{{ openssl_version }}.tar.gz"
dest: "/tmp/{{ openssl_version }}.tar.gz" dest: "/tmp/{{ openssl_version }}.tar.gz"
register: openssl_source register: openssl_source
- name: "(Install: Linux) Install OpenSSL Dependency: Unpack" - name: "(Install: Linux) Unpack OpenSSL Dependency"
unarchive: unarchive:
copy: no copy: no
dest: /tmp/ dest: /tmp/
src: "{{ openssl_source.dest }}" src: "{{ openssl_source.dest }}"
register: openssl_source_unpack register: openssl_source_unpack
- name: "(Install: Linux) Install OpenSSL Dependency: Configure" - name: "(Install: Linux) Configure OpenSSL Dependency"
command: "./config --prefix=/usr" command: "./config --prefix=/usr"
args: args:
chdir: "/tmp/{{ openssl_version }}" chdir: "/tmp/{{ openssl_version }}"
register: openssl_configure register: openssl_configure
- name: "(Install: Linux) Install OpenSSL Dependency: Make" - name: "(Install: Linux) Make OpenSSL Dependency"
make: make:
chdir: "/tmp/{{ openssl_version }}" chdir: "/tmp/{{ openssl_version }}"
- name: "(Install: Linux) Install OpenSSL Dependency: Install" - name: "(Install: Linux) Install OpenSSL Dependency"
make: make:
chdir: "/tmp/{{ openssl_version }}" chdir: "/tmp/{{ openssl_version }}"
target: install target: install
when:
- not openssl_result.stat.exists
- not nginx_install_source_openssl
- name: "(Install: Linux) Install NGINX: Get NGINX version" - name: "(Install: Linux) Get NGINX Version"
block: block:
- name: "(Install: Linux) Fetch NGINX Version"
uri:
url: https://trac.nginx.org/nginx/browser
return_content: true
register: nginx_versions
- name: "(Install: Linux) Install NGINX: Get NGINX mainline version" - name: "(Install: Linux) Set NGINX Mainline Version"
shell: set_fact:
args: nginx_version: "{{ nginx_versions.content | regex_search('release[^<]*') | regex_replace('release', 'nginx') }}"
cmd: curl --stderr - https://trac.nginx.org/nginx/browser | grep release | head -1 | sed -e 's:.*<option value="[^"]*">release\([^<]*\)<.*:nginx\1:' # noqa 204 303
register: nginx_mainline_version
changed_when: false
when: nginx_branch == "mainline" when: nginx_branch == "mainline"
- name: "(Install: Linux) Install NGINX: Set NGINX mainline version" - name: "(Install: Linux) Set NGINX Stable Version 1/2"
set_fact: set_fact:
nginx_version: "{{ nginx_mainline_version.stdout }}" nginx_version: "{{ nginx_versions.content | regex_search('stable[^<]*') | regex_replace('stable', 'release') }}"
when: nginx_branch == "mainline"
- name: "(Install: Linux) Install NGINX: Get NGINX stable version 1/2"
shell:
args:
cmd: curl --stderr - https://trac.nginx.org/nginx/browser | grep stable | head -1 | sed -e 's:.*<option value="[^"]*">stable\([^<]*\)<.*:release\1:' # noqa 204 303
register: nginx_tmp_version
changed_when: false
when: nginx_branch == "stable" when: nginx_branch == "stable"
- name: "(Install: Linux) Install NGINX: Get NGINX stable version 2/2" - name: "(Install: Linux) Set NGINX Stable Version 2/2"
shell:
args:
cmd: curl --stderr - https://trac.nginx.org/nginx/browser | grep {{ nginx_tmp_version.stdout }} | head -1 | sed -e 's:.*<option value="[^"]*">release\([^<]*\)<.*:nginx\1:' # noqa 204 303
register: nginx_stable_version
changed_when: false
when: nginx_branch == "stable"
- name: "(Install: Linux) Install NGINX: Set NGINX stable version"
set_fact: set_fact:
nginx_version: "{{ nginx_stable_version.stdout }}" nginx_version: "{{ nginx_versions.content | regex_search(nginx_version + '[^<]*') | regex_replace('release', 'nginx') }}"
when: nginx_branch == "stable" when: nginx_branch == "stable"
- name: "(Install: Linux) Install NGINX: Set NGINX download filename" - name: "(Install: Linux) Set NGINX Download Filename"
set_fact: set_fact:
nginx_download_name: "{{ nginx_version }}" nginx_download_name: "{{ nginx_version }}"
when: nginx_branch == "stable" or nginx_branch == "mainline"
- name: "(Install: Linux) Check for NGINX Install" - name: "(Install: Linux) Check For NGINX Install"
stat: stat:
path: /usr/sbin/nginx path: /usr/sbin/nginx
follow: true follow: true
@ -298,23 +304,21 @@
name: nginx name: nginx
- name: "(Install: Linux) Install NGINX" - name: "(Install: Linux) Install NGINX"
when: not nginx_result.stat.exists
block: block:
- name: "(Install: Linux) Download NGINX"
- name: "(Install: Linux) Install NGINX: Download"
get_url: get_url:
url: "http://nginx.org/download/{{ nginx_download_name }}.tar.gz" url: "http://nginx.org/download/{{ nginx_download_name }}.tar.gz"
dest: "/tmp/{{ nginx_download_name }}.tar.gz" dest: "/tmp/{{ nginx_download_name }}.tar.gz"
register: nginx_source register: nginx_source
- name: "(Install: Linux) Install NGINX: Unpack" - name: "(Install: Linux) Unpack NGINX"
unarchive: unarchive:
copy: no copy: no
dest: /tmp/ dest: /tmp/
src: "{{ nginx_source.dest }}" src: "{{ nginx_source.dest }}"
register: nginx_source_unpack register: nginx_source_unpack
- name: "(Install: Linux) Install NGINX: Configure" - name: "(Install: Linux) Configure NGINX"
command: >- command: >-
./configure ./configure
--prefix=/usr --prefix=/usr
@ -334,16 +338,16 @@
chdir: "/tmp/{{ nginx_version }}" chdir: "/tmp/{{ nginx_version }}"
register: nginx_configure register: nginx_configure
- name: "(Install: Linux) Install NGINX: Make" - name: "(Install: Linux) Make NGINX"
make: make:
chdir: "/tmp/{{ nginx_version }}" chdir: "/tmp/{{ nginx_version }}"
- name: "(Install: Linux) Install NGINX: Install" - name: "(Install: Linux) Install NGINX"
make: make:
chdir: "/tmp/{{ nginx_version }}" chdir: "/tmp/{{ nginx_version }}"
target: install target: install
- name: "(Install: Linux) Upload systemd NGINX service file" - name: "(Install: Linux) Upload systemd NGINX Service File"
copy: copy:
src: services/nginx.systemd src: services/nginx.systemd
dest: /lib/systemd/system/nginx.service dest: /lib/systemd/system/nginx.service
@ -352,7 +356,7 @@
mode: '0644' mode: '0644'
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd"
- name: "(Install: Linux) Enable systemd NGINX service file" - name: "(Install: Linux) Enable systemd NGINX Service File"
systemd: systemd:
daemon_reload: yes daemon_reload: yes
name: nginx name: nginx
@ -361,7 +365,7 @@
notify: "(Handler: All OSs) Start NGINX" notify: "(Handler: All OSs) Start NGINX"
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd"
- name: "(Install: Linux) Upload upstart NGINX service file" - name: "(Install: Linux) Upload upstart NGINX Service File"
copy: copy:
src: services/nginx.upstart src: services/nginx.upstart
dest: /etc/init.d/nginx dest: /etc/init.d/nginx
@ -370,7 +374,7 @@
mode: '0755' mode: '0755'
when: ansible_service_mgr == "upstart" when: ansible_service_mgr == "upstart"
- name: "(Install: Linux) Upload upstart NGINX service conf file" - name: "(Install: Linux) Upload upstart NGINX Service Conf File"
copy: copy:
src: services/nginx.conf.upstart src: services/nginx.conf.upstart
dest: /etc/init/nginx.conf dest: /etc/init/nginx.conf
@ -379,16 +383,16 @@
mode: '0644' mode: '0644'
when: ansible_service_mgr == "upstart" when: ansible_service_mgr == "upstart"
- name: "(Install: Linux) Enable upstart NGINX service reload" - name: "(Install: Linux) Enable upstart NGINX Service Reload"
command: "initctl reload-configuration" command: "initctl reload-configuration"
when: ansible_service_mgr == "upstart" when: ansible_service_mgr == "upstart"
- name: "(Install: Linux) Start upstart NGINX service reload" - name: "(Install: Linux) Start upstart NGINX Service Reload"
command: "nginx" command: "nginx"
notify: "(Handler: All OSs) Start NGINX" notify: "(Handler: All OSs) Start NGINX"
when: ansible_service_mgr == "upstart" when: ansible_service_mgr == "upstart"
- name: "(Install: Linux) Upload sysvinit NGINX service file" - name: "(Install: Linux) Upload sysvinit NGINX Service File"
copy: copy:
src: services/nginx.sysvinit src: services/nginx.sysvinit
dest: /etc/init.d/nginx dest: /etc/init.d/nginx
@ -398,7 +402,7 @@
notify: "(Handler: All OSs) Start NGINX" notify: "(Handler: All OSs) Start NGINX"
when: ansible_service_mgr == "sysvinit" when: ansible_service_mgr == "sysvinit"
- name: "(Install: Linux) Upload openrc NGINX service file" - name: "(Install: Linux) Upload openrc NGINX Service File"
copy: copy:
src: services/nginx.openrc src: services/nginx.openrc
dest: /etc/init.d/nginx dest: /etc/init.d/nginx
@ -407,12 +411,13 @@
mode: '0755' mode: '0755'
when: ansible_service_mgr == "openrc" when: ansible_service_mgr == "openrc"
- name: "(Install: Linux) Enable openrc NGINX service" - name: "(Install: Linux) Enable openrc NGINX Service"
command: rc-update add nginx default command: rc-update add nginx default
notify: "(Handler: All OSs) Start NGINX" notify: "(Handler: All OSs) Start NGINX"
when: ansible_service_mgr == "openrc" when: ansible_service_mgr == "openrc"
when: not nginx_result.stat.exists
- name: "(Install: Linux) Install NGINX: Cleanup Downloads" - name: "(Install: Linux) Cleanup Downloads"
file: file:
path: "{{ item }}" path: "{{ item }}"
state: absent state: absent

View File

@ -5,3 +5,4 @@
- apt-transport-https - apt-transport-https
- dirmngr - dirmngr
- python-apt - python-apt
update_cache: true