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
This commit is contained in:
Alessandro Fael Garcia 2018-06-27 13:16:57 -07:00
parent 3a8e36e636
commit bd0c581ac1
5 changed files with 12 additions and 92 deletions

View File

@ -31,7 +31,7 @@ branch: mainline
# Install NGINX Unit and NGINX Unit packages. # Install NGINX Unit and NGINX Unit packages.
# Default is false. # Default is false.
unit_enable: 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. # Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
# Default is false. # Default is false.

View File

@ -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"

View File

@ -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"

View File

@ -11,5 +11,5 @@
state: present state: present
notify: "(Handler: All OSs) Start NGINX Unit" notify: "(Handler: All OSs) Start NGINX Unit"
- import_tasks: install-packages.yml - import_tasks: install-modules.yml
when: unit_packages when: unit_modules is defined and unit_modules

View File

@ -6,4 +6,6 @@
- ansible-role-nginx - ansible-role-nginx
vars: vars:
unit_enable: true unit_enable: true
unit_packages: true unit_modules:
- unit-php
- unit-perl