Skip to content

Commit fa9f2ae

Browse files
authored
Merge pull request #37 from nginxinc/(feature)/unit
(feature)/unit
2 parents ba092d0 + 7c66da1 commit fa9f2ae

File tree

12 files changed

+197
-13
lines changed

12 files changed

+197
-13
lines changed

.travis.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ env:
1515
- distribution: centos
1616
version: 6
1717
playbook: template
18+
- distribution: centos
19+
version: 6
20+
playbook: unit
1821
- distribution: centos
1922
version: 7
2023
playbook: basic
@@ -27,6 +30,9 @@ env:
2730
- distribution: centos
2831
version: 7
2932
playbook: push
33+
- distribution: centos
34+
version: 7
35+
playbook: unit
3036
- distribution: debian
3137
version: jessie
3238
playbook: basic
@@ -39,6 +45,9 @@ env:
3945
- distribution: debian
4046
version: jessie
4147
playbook: push
48+
- distribution: debian
49+
version: jessie
50+
playbook: unit
4251
- distribution: debian
4352
version: stretch
4453
playbook: basic
@@ -51,6 +60,9 @@ env:
5160
- distribution: debian
5261
version: stretch
5362
playbook: push
63+
- distribution: debian
64+
version: stretch
65+
playbook: unit
5466
- distribution: ubuntu
5567
version: trusty
5668
playbook: basic
@@ -75,6 +87,39 @@ env:
7587
- distribution: ubuntu
7688
version: xenial
7789
playbook: push
90+
- distribution: ubuntu
91+
version: xenial
92+
playbook: unit
93+
- distribution: ubuntu
94+
version: artful
95+
playbook: basic
96+
- distribution: ubuntu
97+
version: artful
98+
playbook: push
99+
- distribution: ubuntu
100+
version: artful
101+
playbook: stable
102+
- distribution: ubuntu
103+
version: artful
104+
playbook: template
105+
- distribution: ubuntu
106+
version: artful
107+
playbook: unit
108+
- distribution: ubuntu
109+
version: bionic
110+
playbook: basic
111+
- distribution: ubuntu
112+
version: bionic
113+
playbook: push
114+
- distribution: ubuntu
115+
version: bionic
116+
playbook: stable
117+
- distribution: ubuntu
118+
version: bionic
119+
playbook: template
120+
- distribution: ubuntu
121+
version: bionic
122+
playbook: unit
78123
before_install:
79124
- 'sudo docker pull ${distribution}:${version}'
80125
- 'sudo docker build --no-cache --rm --file=tests/dockerfiles/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'

README.md

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Ansible NGINX Role
44
[![Ansible Galaxy](https://img.shields.io/badge/galaxy-nginxinc.nginx-5bbdbf.svg)](https://galaxy.ansible.com/nginxinc/nginx)
55
[![Build Status](https://travis-ci.org/nginxinc/ansible-role-nginx.svg?branch=master)](https://travis-ci.org/nginxinc/ansible-role-nginx)
66

7-
This role installs NGINX Open Source or NGINX Plus on your target host.
7+
This role installs NGINX Open Source, NGINX Plus, or NGINX Unit on your target host.
88

99
Requirements
1010
------------
@@ -40,35 +40,58 @@ It supports all platforms supported by [NGINX Open Source](https://nginx.org/en/
4040

4141
**NGINX Plus:**
4242

43-
CentOS:
44-
versions:
45-
- 6
46-
- 7
47-
RedHat:
48-
versions:
49-
- 6
50-
- 7
5143
Debian:
5244
versions:
53-
- wheezy
5445
- jessie
5546
- stretch
5647
Ubuntu:
5748
versions:
5849
- trusty
5950
- xenial
6051
- zesty
52+
- artful
53+
CentOS:
54+
versions:
55+
- 6.5
56+
- 7
57+
RedHat:
58+
versions:
59+
- 6.5
60+
- 7
61+
Oracle Linux:
62+
versions:
63+
- 6.5
64+
- 7
65+
Amazon Linux:
66+
versions:
67+
- 2016.09
6168
SUSE/SLES:
6269
versions:
6370
- 12
6471
FreeBSD:
6572
versions:
6673
- 10.3
6774
- 11
68-
Oracle Linux:
75+
76+
**NGINX Unit:**
77+
78+
CentOS:
6979
versions:
70-
- 6.5
80+
- 6
81+
- 7
82+
RedHat:
83+
versions:
84+
- 6
7185
- 7
86+
Debian:
87+
versions:
88+
- jessie
89+
- stretch
90+
Ubuntu:
91+
versions:
92+
- xenial
93+
- artful
94+
- bionic
7295
Amazon Linux:
7396
versions:
7497
- 2016.09
@@ -108,8 +131,12 @@ This role has multiple variables. The defaults for all these variables are the f
108131
# Default is mainline.
109132
branch: mainline
110133

111-
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
134+
# Install NGINX Unit and NGINX Unit packages.
112135
# Default is false.
136+
unit_enable: false
137+
unit_packages: false
138+
139+
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules. # Default is false.
113140
modules:
114141
njs: false
115142
perl: false
@@ -200,6 +227,17 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role to a
200227
roles:
201228
- role: nginxinc.nginx
202229

230+
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.
231+
232+
---
233+
- hosts: localhost
234+
become: true
235+
roles:
236+
- role: nginxinc.nginx
237+
vars:
238+
- unit_enable: true
239+
- unit_packages: true
240+
203241
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`.
204242

205243
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`.

defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ nginx_repository:
2828
# Default is mainline.
2929
branch: mainline
3030

31+
# Install NGINX Unit and NGINX Unit modules.
32+
# Use a list of supported NGINX Unit modules.
33+
# Default is false.
34+
unit_enable: false
35+
unit_modules: null
36+
3137
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
3238
# Default is false.
3339
modules:

handlers/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@
1010
service:
1111
name: nginx
1212
state: reloaded
13+
14+
- name: "(Handler: All OSs) Start NGINX Unit"
15+
service:
16+
name: unit
17+
state: started

tasks/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@
4646

4747
- import_tasks: amplify/install-amplify.yml
4848
when: amplify_enable and amplify_key is defined and amplify_key
49+
50+
- import_tasks: unit/install-unit.yml
51+
when: unit_enable

tasks/unit/install-modules.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- name: "(Install: All OSs) Install NGINX Unit Modules"
2+
package:
3+
name: "{{ item }}"
4+
state: present
5+
with_items: "{{ unit_modules }}"
6+
notify: "(Handler: All OSs) Start NGINX Unit"

tasks/unit/install-unit.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- import_tasks: setup-debian.yml
3+
when: ansible_os_family == "Debian"
4+
5+
- import_tasks: setup-redhat.yml
6+
when: ansible_os_family == "RedHat"
7+
8+
- name: "(Install: All OSs) Install NGINX Unit"
9+
package:
10+
name: unit
11+
state: present
12+
notify: "(Handler: All OSs) Start NGINX Unit"
13+
14+
- import_tasks: install-modules.yml
15+
when: unit_modules is defined and unit_modules

tasks/unit/setup-debian.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: "(Install: Debian/Ubuntu) Add NGINX Unit Repository"
3+
apt_repository:
4+
repo: "{{ item }}"
5+
with_items:
6+
- deb https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit
7+
- deb-src https://packages.nginx.org/unit/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} unit

tasks/unit/setup-redhat.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: "(Install: CentOS/RedHat) Add NGINX Unit Repository"
3+
yum_repository:
4+
name: unit
5+
baseurl: https://packages.nginx.org/unit/{{ (ansible_distribution == "RedHat") | ternary('rhel/', 'centos/') }}$releasever/$basearch/
6+
description: NGINX Unit Repository
7+
enabled: yes
8+
gpgcheck: yes
9+
when: ansible_distribution != "Amazon"
10+
11+
- name: "(Install: Amazon Linux) Add NGINX Unit Repository"
12+
yum_repository:
13+
name: unit
14+
baseurl: https://packages.nginx.org/unit/amzn/$releasever/$basearch/
15+
description: NGINX Unit Repository
16+
enabled: yes
17+
gpgcheck: yes
18+
when: ansible_distribution == "Amazon"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ubuntu:artful
2+
3+
RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y software-properties-common && rm -rf /var/lib/apt/lists/*
4+
5+
RUN apt-add-repository -y ppa:ansible/ansible && apt-get update && apt-get install -y \
6+
git \
7+
ansible \
8+
apt-transport-https \
9+
curl \
10+
init \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
14+
15+
ENTRYPOINT ["/sbin/init"]

0 commit comments

Comments
 (0)