Skip to content

Commit 548fc3f

Browse files
committed
Initial implementation of NGINX Unit
1 parent 4fa9a51 commit 548fc3f

File tree

4 files changed

+144
-0
lines changed

4 files changed

+144
-0
lines changed

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/unit/install-unit.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
- name: "(Install: All OSs) Install NGINX Unit"
15+
package:
16+
name: "{{ item }}"
17+
state: present
18+
with_items:
19+
- unit-php
20+
- unit-python
21+
- unit-go
22+
- unit-perl
23+
when: ansible_distribution == "CentOS"
24+
notify: "(Handler: All OSs) Start NGINX Unit"
25+
26+
- name: "(Install: All OSs) Install NGINX Unit"
27+
package:
28+
name: "{{ item }}"
29+
state: present
30+
with_items:
31+
- unit-php
32+
- unit-python
33+
- unit-perl
34+
when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6
35+
notify: "(Handler: All OSs) Start NGINX Unit"
36+
37+
- name: "(Install: All OSs) Install NGINX Unit"
38+
package:
39+
name: "{{ item }}"
40+
state: present
41+
with_items:
42+
- unit-php
43+
- unit-python
44+
- unit-go
45+
- unit-perl
46+
when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 6
47+
notify: "(Handler: All OSs) Start NGINX Unit"
48+
49+
- name: "(Install: All OSs) Install NGINX Unit"
50+
package:
51+
name: "{{ item }}"
52+
state: present
53+
with_items:
54+
- unit-php
55+
- unit-python27
56+
- unit-python34
57+
- unit-python35
58+
- unit-python36
59+
- unit-go
60+
- unit-perl
61+
when: ansible_distribution == "Amazon"
62+
notify: "(Handler: All OSs) Start NGINX Unit"
63+
64+
- name: "(Install: All OSs) Install NGINX Unit"
65+
package:
66+
name: "{{ item }}"
67+
state: present
68+
with_items:
69+
- unit-php
70+
- unit-python2.7
71+
- unit-python3.5
72+
- unit-go
73+
- unit-perl
74+
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 16
75+
notify: "(Handler: All OSs) Start NGINX Unit"
76+
77+
- name: "(Install: All OSs) Install NGINX Unit"
78+
package:
79+
name: "{{ item }}"
80+
state: present
81+
with_items:
82+
- unit-php
83+
- unit-python2.7
84+
- unit-python3.4
85+
- unit-perl
86+
when: ansible_distribution == "Debian" and ansible_distribution_major_version|int == 8
87+
notify: "(Handler: All OSs) Start NGINX Unit"
88+
89+
- name: "(Install: All OSs) Install NGINX Unit"
90+
package:
91+
name: "{{ item }}"
92+
state: present
93+
with_items:
94+
- unit-php
95+
- unit-python2.7
96+
- unit-python3.5
97+
- unit-go1.7
98+
- unit-go1.8
99+
- unit-perl
100+
when: ansible_distribution == "RedHat" and ansible_distribution_major_version|int == 9
101+
notify: "(Handler: All OSs) Start NGINX Unit"

tasks/unit/setup-debian.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
8+
9+
- name: "(Install: Debian/Ubuntu) Update APT Cache"
10+
apt:
11+
update_cache: yes

tasks/unit/setup-redhat.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
- name: "(Install: RedHat) Add NGINX Unit Repository"
3+
yum_repository:
4+
name: nginx
5+
baseurl: https://packages.nginx.org/unit/rhel/$releasever/$basearch/
6+
description: NGINX Repository
7+
enabled: yes
8+
gpgcheck: yes
9+
when: ansible_distribution == "RedHat"
10+
11+
- name: "(Install: CentOS) Add NGINX Unit Repository"
12+
yum_repository:
13+
name: nginx
14+
baseurl: https://packages.nginx.org/unit/centos/$releasever/$basearch/
15+
description: NGINX Repository
16+
enabled: yes
17+
gpgcheck: yes
18+
when: ansible_distribution == "CentOS"
19+
20+
- name: "(Install: Amazon Linux) Add NGINX Unit Repository"
21+
yum_repository:
22+
name: nginx
23+
baseurl: https://packages.nginx.org/unit/amzn/$releasever/$basearch/
24+
description: NGINX Repository
25+
enabled: yes
26+
gpgcheck: yes
27+
when: ansible_distribution == "Amazon"

0 commit comments

Comments
 (0)