From 548fc3f9f38d687683aabd0005e6c4b7cf111043 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Fri, 6 Apr 2018 16:32:48 -0700 Subject: [PATCH 01/12] Initial implementation of NGINX Unit --- handlers/main.yml | 5 ++ tasks/unit/install-unit.yml | 101 ++++++++++++++++++++++++++++++++++++ tasks/unit/setup-debian.yml | 11 ++++ tasks/unit/setup-redhat.yml | 27 ++++++++++ 4 files changed, 144 insertions(+) create mode 100644 tasks/unit/install-unit.yml create mode 100644 tasks/unit/setup-debian.yml create mode 100644 tasks/unit/setup-redhat.yml diff --git a/handlers/main.yml b/handlers/main.yml index 1404c0c..c674128 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -10,3 +10,8 @@ service: name: nginx state: reloaded + +- name: "(Handler: All OSs) Start NGINX Unit" + service: + name: unit + state: started diff --git a/tasks/unit/install-unit.yml b/tasks/unit/install-unit.yml new file mode 100644 index 0000000..d27eb8f --- /dev/null +++ b/tasks/unit/install-unit.yml @@ -0,0 +1,101 @@ +--- +- import_tasks: setup-debian.yml + when: ansible_os_family == "Debian" + +- import_tasks: setup-redhat.yml + when: ansible_os_family == "RedHat" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: unit + state: present + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python + - unit-go + - unit-perl + when: ansible_distribution == "CentOS" + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python + - unit-perl + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python + - unit-go + - unit-perl + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python27 + - unit-python34 + - unit-python35 + - unit-python36 + - unit-go + - unit-perl + when: ansible_distribution == "Amazon" + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.5 + - unit-go + - unit-perl + when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.4 + - unit-perl + when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: All OSs) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.5 + - unit-go1.7 + - unit-go1.8 + - unit-perl + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 9 + notify: "(Handler: All OSs) Start NGINX Unit" diff --git a/tasks/unit/setup-debian.yml b/tasks/unit/setup-debian.yml new file mode 100644 index 0000000..114fc45 --- /dev/null +++ b/tasks/unit/setup-debian.yml @@ -0,0 +1,11 @@ +--- +- name: "(Install: Debian/Ubuntu) Add NGINX Unit Repository" + apt_repository: + repo: "{{ item }}" + with_items: + - deb https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit + - deb-src https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit + +- name: "(Install: Debian/Ubuntu) Update APT Cache" + apt: + update_cache: yes diff --git a/tasks/unit/setup-redhat.yml b/tasks/unit/setup-redhat.yml new file mode 100644 index 0000000..05e6c6f --- /dev/null +++ b/tasks/unit/setup-redhat.yml @@ -0,0 +1,27 @@ +--- +- name: "(Install: RedHat) Add NGINX Unit Repository" + yum_repository: + name: nginx + baseurl: https://packages.nginx.org/unit/rhel/$releasever/$basearch/ + description: NGINX Repository + enabled: yes + gpgcheck: yes + when: ansible_distribution == "RedHat" + +- name: "(Install: CentOS) Add NGINX Unit Repository" + yum_repository: + name: nginx + baseurl: https://packages.nginx.org/unit/centos/$releasever/$basearch/ + description: NGINX Repository + enabled: yes + gpgcheck: yes + when: ansible_distribution == "CentOS" + +- name: "(Install: Amazon Linux) Add NGINX Unit Repository" + yum_repository: + name: nginx + baseurl: https://packages.nginx.org/unit/amzn/$releasever/$basearch/ + description: NGINX Repository + enabled: yes + gpgcheck: yes + when: ansible_distribution == "Amazon" From 8a8f08a9975634db15e40519c0640bb1ae2451f1 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Mon, 9 Apr 2018 14:21:38 -0700 Subject: [PATCH 02/12] Add NGINX Unit variables * Add unit_enable variable to install NGINX Unit * Add unit_packages variable to determine whether NGINX Unit packages should be installed --- defaults/main.yml | 5 ++++ tasks/main.yml | 3 +++ tasks/unit/install-unit.yml | 48 ++++++++++++++++++------------------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 168aaf0..7e88205 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -9,6 +9,11 @@ type: opensource # Default is mainline. branch: mainline +# Install NGINX Unit and NGINX Unit packages. +# Default is false. +unit_enable: false +unit_packages: false + # Install nginscript, perl, waf (NGINX Plus only), geoip, image-filter, rtmp and/or xslt modules. # Default is false. modules: diff --git a/tasks/main.yml b/tasks/main.yml index 0a2ab93..2572896 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -46,3 +46,6 @@ - import_tasks: amplify/install-amplify.yml when: amplify_enable and amplify_key is defined and amplify_key + +- import_tasks: unit/install-unit.yml + when: unit_enable diff --git a/tasks/unit/install-unit.yml b/tasks/unit/install-unit.yml index d27eb8f..bdc659c 100644 --- a/tasks/unit/install-unit.yml +++ b/tasks/unit/install-unit.yml @@ -11,7 +11,7 @@ state: present notify: "(Handler: All OSs) Start NGINX Unit" -- name: "(Install: All OSs) Install NGINX Unit" +- name: "(Install: CentOS) Install NGINX Unit Packages" package: name: "{{ item }}" state: present @@ -20,10 +20,10 @@ - unit-python - unit-go - unit-perl - when: ansible_distribution == "CentOS" + when: ansible_distribution == "CentOS" and unit_packages notify: "(Handler: All OSs) Start NGINX Unit" -- name: "(Install: All OSs) Install NGINX Unit" +- name: "(Install: RedHat) Install NGINX Unit Packages" package: name: "{{ item }}" state: present @@ -31,10 +31,10 @@ - unit-php - unit-python - unit-perl - when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 and unit_packages notify: "(Handler: All OSs) Start NGINX Unit" -- name: "(Install: All OSs) Install NGINX Unit" +- name: "(Install: RedHat) Install NGINX Unit Packages" package: name: "{{ item }}" state: present @@ -43,10 +43,10 @@ - unit-python - unit-go - unit-perl - when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 7 and unit_packages notify: "(Handler: All OSs) Start NGINX Unit" -- name: "(Install: All OSs) Install NGINX Unit" +- name: "(Install: Amazon Linux) Install NGINX Unit Packages" package: name: "{{ item }}" state: present @@ -61,20 +61,7 @@ when: ansible_distribution == "Amazon" notify: "(Handler: All OSs) Start NGINX Unit" -- name: "(Install: All OSs) Install NGINX Unit" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python2.7 - - unit-python3.5 - - unit-go - - unit-perl - when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16 - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: All OSs) Install NGINX Unit" +- name: "(Install: Debian 8) Install NGINX Unit" package: name: "{{ item }}" state: present @@ -83,10 +70,10 @@ - unit-python2.7 - unit-python3.4 - unit-perl - when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8 + when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8 and unit_packages notify: "(Handler: All OSs) Start NGINX Unit" -- name: "(Install: All OSs) Install NGINX Unit" +- name: "(Install: Debian 9) Install NGINX Unit" package: name: "{{ item }}" state: present @@ -97,5 +84,18 @@ - unit-go1.7 - unit-go1.8 - unit-perl - when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 9 + when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 9 and unit_packages + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: Ubuntu) Install NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.5 + - unit-go + - unit-perl + when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16 and unit_packages notify: "(Handler: All OSs) Start NGINX Unit" From 0ed9afb71aecc3212fa3459c9fbbc38fff7d63cd Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Mon, 9 Apr 2018 14:22:13 -0700 Subject: [PATCH 03/12] Add NGINX Unit documentation --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 6f7f205..e969684 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Ansible NGINX Role [![Ansible Galaxy](https://img.shields.io/badge/galaxy-nginxinc.nginx-5bbdbf.svg)](https://galaxy.ansible.com/nginxinc/nginx) [![Build Status](https://travis-ci.org/nginxinc/ansible-role-nginx.svg?branch=master)](https://travis-ci.org/nginxinc/ansible-role-nginx) -This role installs open source NGINX or NGINX Plus on your target host. +This role installs open source NGINX, NGINX Plus, or NGINX Unit on your target host. Requirements ------------ @@ -40,6 +40,41 @@ It supports all platforms supported by [open source NGINX](https://nginx.org/en/ **NGINX Plus:** + Debian: + versions: + - jessie + - stretch + Ubuntu: + versions: + - trusty + - xenial + - zesty + - artful + CentOS: + versions: + - 6.5 + - 7 + RedHat: + versions: + - 6.5 + - 7 + Oracle Linux: + versions: + - 6.5 + - 7 + Amazon Linux: + versions: + - 2016.09 + SUSE/SLES: + versions: + - 12 + FreeBSD: + versions: + - 10.3 + - 11 + +**NGINX Unit:** + CentOS: versions: - 6 @@ -50,25 +85,12 @@ It supports all platforms supported by [open source NGINX](https://nginx.org/en/ - 7 Debian: versions: - - wheezy - jessie - stretch Ubuntu: versions: - - trusty - xenial - - zesty - SUSE/SLES: - versions: - - 12 - FreeBSD: - versions: - - 10.3 - - 11 - Oracle Linux: - versions: - - 6.5 - - 7 + - artful Amazon Linux: versions: - 2016.09 @@ -89,6 +111,11 @@ This role has multiple variables. The defaults for all these variables are the f # Default is mainline. branch: mainline + # Install NGINX Unit and NGINX Unit packages. + # Default is false. + unit_enable: false + unit_packages: false + # Install nginscript, perl, waf (NGINX Plus only), geoip, image-filter, rtmp and/or xslt modules. # Default is false. modules: @@ -184,6 +211,17 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role to a roles: - role: nginxinc.nginx +This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a localhost to install NGINX Unit and all NGINX Unit language packages. + + --- + - hosts: localhost + become: true + roles: + - role: nginxinc.nginx + vars: + - unit_enable: true + - unit_packages: true + To run any of the above sample playbooks create a `setup-nginx.yml` file and paste the contents. Executing the Ansible Playbook is then as simple as executing `ansible-playbook setup-nginx.yml`. Alternatively, you can also clone this repository instead of installing it from Ansible Galaxy. If you decide to do so, replace the role variable in the previous sample playbooks from `nginxinc.nginx` to `ansible-role-nginx`. From ce880e57310d25e6258a3fc6b459c4945adeabc8 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Thu, 10 May 2018 13:03:22 -0700 Subject: [PATCH 04/12] Refactor NGINX Unit packages into a separate file --- tasks/unit/install-packages.yml | 88 ++++++++++++++++++++++++++++++++ tasks/unit/install-unit.yml | 90 +-------------------------------- 2 files changed, 90 insertions(+), 88 deletions(-) create mode 100644 tasks/unit/install-packages.yml diff --git a/tasks/unit/install-packages.yml b/tasks/unit/install-packages.yml new file mode 100644 index 0000000..34898c7 --- /dev/null +++ b/tasks/unit/install-packages.yml @@ -0,0 +1,88 @@ +- name: "(Install: CentOS) Install NGINX Unit Packages" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python + - unit-go + - unit-perl + when: ansible_distribution == "CentOS" + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: RedHat 6) Install NGINX Unit Packages" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python + - unit-perl + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: RedHat 7) Install NGINX Unit Packages" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python + - unit-go + - unit-perl + when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 7 + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: Amazon Linux) Install NGINX Unit Packages" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python27 + - unit-python34 + - unit-python35 + - unit-python36 + - unit-go + - unit-perl + when: ansible_distribution == "Amazon" + notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: Debian Jessie) Install NGINX Unit" +package: + name: "{{ item }}" + state: present +with_items: + - unit-php + - unit-python2.7 + - unit-python3.4 + - unit-perl +when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8 +notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: Debian Stretch) Install NGINX Unit" +package: + name: "{{ item }}" + state: present +with_items: + - unit-php + - unit-python2.7 + - unit-python3.5 + - unit-go1.7 + - unit-go1.8 + - unit-perl +when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 9 +notify: "(Handler: All OSs) Start NGINX Unit" + +- name: "(Install: Ubuntu) Install NGINX Unit" +package: + name: "{{ item }}" + state: present +with_items: + - unit-php + - unit-python2.7 + - unit-python3.5 + - unit-go + - unit-perl +when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16 +notify: "(Handler: All OSs) Start NGINX Unit" diff --git a/tasks/unit/install-unit.yml b/tasks/unit/install-unit.yml index bdc659c..b8e6a34 100644 --- a/tasks/unit/install-unit.yml +++ b/tasks/unit/install-unit.yml @@ -11,91 +11,5 @@ state: present notify: "(Handler: All OSs) Start NGINX Unit" -- name: "(Install: CentOS) Install NGINX Unit Packages" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python - - unit-go - - unit-perl - when: ansible_distribution == "CentOS" and unit_packages - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: RedHat) Install NGINX Unit Packages" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python - - unit-perl - when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 and unit_packages - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: RedHat) Install NGINX Unit Packages" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python - - unit-go - - unit-perl - when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 7 and unit_packages - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: Amazon Linux) Install NGINX Unit Packages" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python27 - - unit-python34 - - unit-python35 - - unit-python36 - - unit-go - - unit-perl - when: ansible_distribution == "Amazon" - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: Debian 8) Install NGINX Unit" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python2.7 - - unit-python3.4 - - unit-perl - when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8 and unit_packages - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: Debian 9) Install NGINX Unit" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python2.7 - - unit-python3.5 - - unit-go1.7 - - unit-go1.8 - - unit-perl - when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 9 and unit_packages - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: Ubuntu) Install NGINX Unit" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python2.7 - - unit-python3.5 - - unit-go - - unit-perl - when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16 and unit_packages - notify: "(Handler: All OSs) Start NGINX Unit" +- import_tasks: install-packages.yml + when: unit_packages From 033da6684c9458a8b04a4cfdedafd53ea694dc15 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Thu, 10 May 2018 13:17:37 -0700 Subject: [PATCH 05/12] Fix indentation --- tasks/unit/install-packages.yml | 66 ++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tasks/unit/install-packages.yml b/tasks/unit/install-packages.yml index 34898c7..22553cd 100644 --- a/tasks/unit/install-packages.yml +++ b/tasks/unit/install-packages.yml @@ -49,40 +49,40 @@ notify: "(Handler: All OSs) Start NGINX Unit" - name: "(Install: Debian Jessie) Install NGINX Unit" -package: - name: "{{ item }}" - state: present -with_items: - - unit-php - - unit-python2.7 - - unit-python3.4 - - unit-perl -when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8 -notify: "(Handler: All OSs) Start NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.4 + - unit-perl + when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8 + notify: "(Handler: All OSs) Start NGINX Unit" - name: "(Install: Debian Stretch) Install NGINX Unit" -package: - name: "{{ item }}" - state: present -with_items: - - unit-php - - unit-python2.7 - - unit-python3.5 - - unit-go1.7 - - unit-go1.8 - - unit-perl -when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 9 -notify: "(Handler: All OSs) Start NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.5 + - unit-go1.7 + - unit-go1.8 + - unit-perl + when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 9 + notify: "(Handler: All OSs) Start NGINX Unit" - name: "(Install: Ubuntu) Install NGINX Unit" -package: - name: "{{ item }}" - state: present -with_items: - - unit-php - - unit-python2.7 - - unit-python3.5 - - unit-go - - unit-perl -when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16 -notify: "(Handler: All OSs) Start NGINX Unit" + package: + name: "{{ item }}" + state: present + with_items: + - unit-php + - unit-python2.7 + - unit-python3.5 + - unit-go + - unit-perl + when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16 + notify: "(Handler: All OSs) Start NGINX Unit" From a6d54c858e542a93ca11a20cbb44e39c80cb679a Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Tue, 26 Jun 2018 16:26:24 -0700 Subject: [PATCH 06/12] Merge CentOS and RedHat tasks --- tasks/unit/setup-redhat.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/tasks/unit/setup-redhat.yml b/tasks/unit/setup-redhat.yml index 05e6c6f..a1fe14f 100644 --- a/tasks/unit/setup-redhat.yml +++ b/tasks/unit/setup-redhat.yml @@ -2,20 +2,11 @@ - name: "(Install: RedHat) Add NGINX Unit Repository" yum_repository: name: nginx - baseurl: https://packages.nginx.org/unit/rhel/$releasever/$basearch/ + baseurl: https://packages.nginx.org/unit/{{ (ansible_distribution == "RedHat") | ternary('rhel/', 'centos/') }}$releasever/$basearch/ description: NGINX Repository enabled: yes gpgcheck: yes - when: ansible_distribution == "RedHat" - -- name: "(Install: CentOS) Add NGINX Unit Repository" - yum_repository: - name: nginx - baseurl: https://packages.nginx.org/unit/centos/$releasever/$basearch/ - description: NGINX Repository - enabled: yes - gpgcheck: yes - when: ansible_distribution == "CentOS" + when: ansible_distribution != "Amazon" - name: "(Install: Amazon Linux) Add NGINX Unit Repository" yum_repository: From 2679ee6cb70c07235b45d1209789d3c6bf9d55d3 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Tue, 26 Jun 2018 16:29:31 -0700 Subject: [PATCH 07/12] Add Ubuntu Bionic to supported platforms list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f7331cf..767d12b 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ It supports all platforms supported by [NGINX Open Source](https://nginx.org/en/ versions: - xenial - artful + - bionic Amazon Linux: versions: - 2016.09 From 6bba55e4a24261f535320adcee2755b9ba478148 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Tue, 26 Jun 2018 16:41:35 -0700 Subject: [PATCH 08/12] Add tests --- .travis.yml | 15 +++++++++++++++ tests/dockerfiles/Dockerfile.ubuntu-bionic | 14 ++++++++++++++ tests/playbooks/nginx-unit.yml | 9 +++++++++ 3 files changed, 38 insertions(+) create mode 100644 tests/dockerfiles/Dockerfile.ubuntu-bionic create mode 100644 tests/playbooks/nginx-unit.yml diff --git a/.travis.yml b/.travis.yml index 7838e42..43e39db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,9 @@ env: - distribution: centos version: 6 playbook: template + - distribution: centos + version: 6 + playbook: unit - distribution: centos version: 7 playbook: basic @@ -27,6 +30,9 @@ env: - distribution: centos version: 7 playbook: push + - distribution: centos + version: 7 + playbook: unit - distribution: debian version: jessie playbook: basic @@ -39,6 +45,9 @@ env: - distribution: debian version: jessie playbook: push + - distribution: debian + version: jessie + playbook: unit - distribution: debian version: stretch playbook: basic @@ -51,6 +60,9 @@ env: - distribution: debian version: stretch playbook: push + - distribution: debian + version: stretch + playbook: unit - distribution: ubuntu version: trusty playbook: basic @@ -75,6 +87,9 @@ env: - distribution: ubuntu version: xenial playbook: push + - distribution: ubuntu + version: xenial + playbook: unit before_install: - 'sudo docker pull ${distribution}:${version}' - 'sudo docker build --no-cache --rm --file=tests/dockerfiles/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests' diff --git a/tests/dockerfiles/Dockerfile.ubuntu-bionic b/tests/dockerfiles/Dockerfile.ubuntu-bionic new file mode 100644 index 0000000..708c894 --- /dev/null +++ b/tests/dockerfiles/Dockerfile.ubuntu-bionic @@ -0,0 +1,14 @@ +FROM ubuntu:bionic + +RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y software-properties-common && rm -rf /var/lib/apt/lists/* + +RUN apt-add-repository -y ppa:ansible/ansible && apt-get update && apt-get install -y \ + git \ + ansible \ + apt-transport-https \ + curl \ + && rm -rf /var/lib/apt/lists/* + +RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts + +ENTRYPOINT ["/sbin/init"] diff --git a/tests/playbooks/nginx-unit.yml b/tests/playbooks/nginx-unit.yml new file mode 100644 index 0000000..4228bfc --- /dev/null +++ b/tests/playbooks/nginx-unit.yml @@ -0,0 +1,9 @@ +--- +- hosts: localhost + become: true + remote_user: root + roles: + - ansible-role-nginx + vars: + unit_enable: true + unit_packages: true From 3a8e36e636b28e05656e20f1232a0a1c938158a7 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Wed, 27 Jun 2018 11:07:35 -0700 Subject: [PATCH 09/12] Fix Debian/RedHat setup * Change yum repository from nginx to unit * Remove apt task causing ansible to be non-idempotent --- tasks/unit/setup-debian.yml | 4 ---- tasks/unit/setup-redhat.yml | 10 +++++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tasks/unit/setup-debian.yml b/tasks/unit/setup-debian.yml index 114fc45..8029ab5 100644 --- a/tasks/unit/setup-debian.yml +++ b/tasks/unit/setup-debian.yml @@ -5,7 +5,3 @@ with_items: - deb https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit - deb-src https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit - -- name: "(Install: Debian/Ubuntu) Update APT Cache" - apt: - update_cache: yes diff --git a/tasks/unit/setup-redhat.yml b/tasks/unit/setup-redhat.yml index a1fe14f..232c0c9 100644 --- a/tasks/unit/setup-redhat.yml +++ b/tasks/unit/setup-redhat.yml @@ -1,18 +1,18 @@ --- -- name: "(Install: RedHat) Add NGINX Unit Repository" +- name: "(Install: CentOS/RedHat) Add NGINX Unit Repository" yum_repository: - name: nginx + name: unit baseurl: https://packages.nginx.org/unit/{{ (ansible_distribution == "RedHat") | ternary('rhel/', 'centos/') }}$releasever/$basearch/ - description: NGINX Repository + description: NGINX Unit Repository enabled: yes gpgcheck: yes when: ansible_distribution != "Amazon" - name: "(Install: Amazon Linux) Add NGINX Unit Repository" yum_repository: - name: nginx + name: unit baseurl: https://packages.nginx.org/unit/amzn/$releasever/$basearch/ - description: NGINX Repository + description: NGINX Unit Repository enabled: yes gpgcheck: yes when: ansible_distribution == "Amazon" From bd0c581ac1c6d1bb70b74dc988bde69cb36a5e51 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Wed, 27 Jun 2018 13:16:57 -0700 Subject: [PATCH 10/12] Refactor installation of NGINX Unit modules Use a list that lets users specify which modules they want to install instead of installing all modules available in each distro --- defaults/main.yml | 2 +- tasks/unit/install-modules.yml | 6 +++ tasks/unit/install-packages.yml | 88 --------------------------------- tasks/unit/install-unit.yml | 4 +- tests/playbooks/nginx-unit.yml | 4 +- 5 files changed, 12 insertions(+), 92 deletions(-) create mode 100644 tasks/unit/install-modules.yml delete mode 100644 tasks/unit/install-packages.yml diff --git a/defaults/main.yml b/defaults/main.yml index fb5c893..293fc01 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -31,7 +31,7 @@ branch: mainline # Install NGINX Unit and NGINX Unit packages. # Default is false. unit_enable: false -unit_packages: false +unit_modules: null # Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules. # Default is false. diff --git a/tasks/unit/install-modules.yml b/tasks/unit/install-modules.yml new file mode 100644 index 0000000..fa5fccf --- /dev/null +++ b/tasks/unit/install-modules.yml @@ -0,0 +1,6 @@ +- name: "(Install: All OSs) Install NGINX Unit Modules" + package: + name: "{{ item }}" + state: present + with_items: "{{ unit_modules }}" + notify: "(Handler: All OSs) Start NGINX Unit" diff --git a/tasks/unit/install-packages.yml b/tasks/unit/install-packages.yml deleted file mode 100644 index 22553cd..0000000 --- a/tasks/unit/install-packages.yml +++ /dev/null @@ -1,88 +0,0 @@ -- name: "(Install: CentOS) Install NGINX Unit Packages" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python - - unit-go - - unit-perl - when: ansible_distribution == "CentOS" - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: RedHat 6) Install NGINX Unit Packages" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python - - unit-perl - when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6 - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: RedHat 7) Install NGINX Unit Packages" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python - - unit-go - - unit-perl - when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 7 - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: Amazon Linux) Install NGINX Unit Packages" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python27 - - unit-python34 - - unit-python35 - - unit-python36 - - unit-go - - unit-perl - when: ansible_distribution == "Amazon" - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: Debian Jessie) Install NGINX Unit" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python2.7 - - unit-python3.4 - - unit-perl - when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8 - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: Debian Stretch) Install NGINX Unit" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python2.7 - - unit-python3.5 - - unit-go1.7 - - unit-go1.8 - - unit-perl - when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 9 - notify: "(Handler: All OSs) Start NGINX Unit" - -- name: "(Install: Ubuntu) Install NGINX Unit" - package: - name: "{{ item }}" - state: present - with_items: - - unit-php - - unit-python2.7 - - unit-python3.5 - - unit-go - - unit-perl - when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16 - notify: "(Handler: All OSs) Start NGINX Unit" diff --git a/tasks/unit/install-unit.yml b/tasks/unit/install-unit.yml index b8e6a34..08dd30c 100644 --- a/tasks/unit/install-unit.yml +++ b/tasks/unit/install-unit.yml @@ -11,5 +11,5 @@ state: present notify: "(Handler: All OSs) Start NGINX Unit" -- import_tasks: install-packages.yml - when: unit_packages +- import_tasks: install-modules.yml + when: unit_modules is defined and unit_modules diff --git a/tests/playbooks/nginx-unit.yml b/tests/playbooks/nginx-unit.yml index 4228bfc..cd0472e 100644 --- a/tests/playbooks/nginx-unit.yml +++ b/tests/playbooks/nginx-unit.yml @@ -6,4 +6,6 @@ - ansible-role-nginx vars: unit_enable: true - unit_packages: true + unit_modules: + - unit-php + - unit-perl From f13cf016a833190fe3f66e97249347ed87baecb9 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Wed, 27 Jun 2018 13:36:26 -0700 Subject: [PATCH 11/12] Add tests Add Ubuntu Artful and Ubuntu Bionic tests to Travis --- .travis.yml | 30 ++++++++++++++++++++++ defaults/main.yml | 3 ++- tests/dockerfiles/Dockerfile.ubuntu-artful | 14 ++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/dockerfiles/Dockerfile.ubuntu-artful diff --git a/.travis.yml b/.travis.yml index 43e39db..6521269 100644 --- a/.travis.yml +++ b/.travis.yml @@ -90,6 +90,36 @@ env: - distribution: ubuntu version: xenial playbook: unit + - distribution: ubuntu + version: artful + playbook: basic + - distribution: ubuntu + version: artful + playbook: push + - distribution: ubuntu + version: artful + playbook: stable + - distribution: ubuntu + version: artful + playbook: template + - distribution: ubuntu + version: artful + playbook: unit + - distribution: ubuntu + version: bionic + playbook: basic + - distribution: ubuntu + version: bionic + playbook: push + - distribution: ubuntu + version: bionic + playbook: stable + - distribution: ubuntu + version: bionic + playbook: template + - distribution: ubuntu + version: bionic + playbook: unit before_install: - 'sudo docker pull ${distribution}:${version}' - 'sudo docker build --no-cache --rm --file=tests/dockerfiles/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests' diff --git a/defaults/main.yml b/defaults/main.yml index 293fc01..93b0d37 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -28,7 +28,8 @@ nginx_repository: # Default is mainline. branch: mainline -# Install NGINX Unit and NGINX Unit packages. +# Install NGINX Unit and NGINX Unit modules. +# Use a list of supported NGINX Unit modules. # Default is false. unit_enable: false unit_modules: null diff --git a/tests/dockerfiles/Dockerfile.ubuntu-artful b/tests/dockerfiles/Dockerfile.ubuntu-artful new file mode 100644 index 0000000..1be99b1 --- /dev/null +++ b/tests/dockerfiles/Dockerfile.ubuntu-artful @@ -0,0 +1,14 @@ +FROM ubuntu:artful + +RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y software-properties-common && rm -rf /var/lib/apt/lists/* + +RUN apt-add-repository -y ppa:ansible/ansible && apt-get update && apt-get install -y \ + git \ + ansible \ + apt-transport-https \ + curl \ + && rm -rf /var/lib/apt/lists/* + +RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts + +ENTRYPOINT ["/sbin/init"] From 7c66da1ee439d34cf37f31b24453d8a4cc0d8988 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Wed, 27 Jun 2018 15:13:17 -0700 Subject: [PATCH 12/12] Fix Ubuntu Artful and Ubuntu Bionic Dockerfiles Explicitly install init dependency --- tests/dockerfiles/Dockerfile.ubuntu-artful | 1 + tests/dockerfiles/Dockerfile.ubuntu-bionic | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/dockerfiles/Dockerfile.ubuntu-artful b/tests/dockerfiles/Dockerfile.ubuntu-artful index 1be99b1..607907f 100644 --- a/tests/dockerfiles/Dockerfile.ubuntu-artful +++ b/tests/dockerfiles/Dockerfile.ubuntu-artful @@ -7,6 +7,7 @@ RUN apt-add-repository -y ppa:ansible/ansible && apt-get update && apt-get insta ansible \ apt-transport-https \ curl \ + init \ && rm -rf /var/lib/apt/lists/* RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts diff --git a/tests/dockerfiles/Dockerfile.ubuntu-bionic b/tests/dockerfiles/Dockerfile.ubuntu-bionic index 708c894..bbad82a 100644 --- a/tests/dockerfiles/Dockerfile.ubuntu-bionic +++ b/tests/dockerfiles/Dockerfile.ubuntu-bionic @@ -7,6 +7,7 @@ RUN apt-add-repository -y ppa:ansible/ansible && apt-get update && apt-get insta ansible \ apt-transport-https \ curl \ + init \ && rm -rf /var/lib/apt/lists/* RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts