Skip to content

Commit 31beec2

Browse files
vbotkaalessfg
authored andcommitted
NGINX Plus separate installation of Linux and FreeBSD (#193)
* Added variable nginx_plus_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse'] * Added variable nginx_plus_bsd_systems: ['FreeBSD'] * Added variable nginx_freebsd_extra_packages: ['security/ca_root_nss'] * Installation of Linux moved to install-plus-linux.yml * Installation of FreeBSD moved to install-plus-bsd.yml * Installation of nginx_freebsd_extra_packages moved to tasks/prerequisites/setup-freebsd.yml * Installation of NGINX Plus tested with FreeBSD 12.0; Lint passed
1 parent ce58eea commit 31beec2

File tree

7 files changed

+88
-41
lines changed

7 files changed

+88
-41
lines changed

defaults/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ nginx_start: true
1010
# Print NGINX configuration file to terminal after executing playbook.
1111
nginx_debug_output: false
1212

13-
# Supported systems
13+
# Supported distributions
1414
nginx_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
1515
nginx_bsd_systems: ['FreeBSD', 'NetBSD', 'OpenBSD', 'DragonFlyBSD', 'HardenedBSD']
16+
# Supported distributions NGINX Plus
17+
# https://docs.nginx.com/nginx/technical-specs/
18+
# RedHat={Amazon,CentOS,OracleLinux,RHEL} Debian={Ubuntu,Debian}
19+
nginx_plus_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
20+
nginx_plus_bsd_systems: ['FreeBSD']
1621

1722
# Specify which type of NGINX you want to install.
1823
# Options are 'opensource' or 'plus'.
@@ -80,6 +85,9 @@ nginx_modules:
8085
rtmp: false
8186
xslt: false
8287

88+
# FreeBSD extra packages
89+
nginx_freebsd_extra_packages: ['security/ca_root_nss']
90+
8391
# Install NGINX Amplify.
8492
# Use your NGINX Amplify API key.
8593
# Requires access to either the NGINX stub status or the NGINX Plus REST API.

tasks/plus/install-plus-bsd.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
- name: "(Install: FreeBSD)"
3+
block:
4+
5+
- name: "(Install: FreeBSD) Add NGINX Plus Repository"
6+
blockinfile:
7+
path: /etc/pkg/nginx-plus.conf
8+
create: yes
9+
block: |
10+
nginx-plus: {
11+
URL: pkg+https://plus-pkgs.nginx.com/freebsd/${ABI}/latest
12+
ENABLED: yes
13+
MIRROR_TYPE: SRV
14+
}
15+
16+
- name: "(Install: FreeBSD) Verify NGINX Plus License"
17+
blockinfile:
18+
path: /usr/local/etc/pkg.conf
19+
block: |
20+
PKG_ENV: { SSL_NO_VERIFY_PEER: "1",
21+
SSL_CLIENT_CERT_FILE: "/etc/ssl/nginx/nginx-repo.crt",
22+
SSL_CLIENT_KEY_FILE: "/etc/ssl/nginx/nginx-repo.key" }
23+
24+
- name: "(Install: FreeBSD) Install nginx-plus{{ nginx_version | default('') }}"
25+
pkgng:
26+
name: "nginx-plus{{ nginx_version | default('') }}"
27+
state: present
28+
notify: "(Handler: All OSs) Start NGINX"
29+
30+
when: ansible_system == "FreeBSD"

tasks/plus/install-plus-linux.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
- import_tasks: setup-suse.yml
9+
when: ansible_os_family == "Suse"
10+
11+
- import_tasks: setup-alpine.yml
12+
when: ansible_os_family == "Alpine"
13+
14+
- name: "(Install: Linux) Install NGINX Plus"
15+
package:
16+
name: "nginx-plus{{ nginx_version | default('') }}"
17+
state: present
18+
notify: "(Handler: All OSs) Start NGINX"

tasks/plus/install-plus.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
---
2-
- import_tasks: setup-license.yml
2+
- name: "(Install: All OSs) Setup license"
3+
import_tasks: setup-license.yml
34

4-
- import_tasks: setup-alpine.yml
5-
when: ansible_os_family == "Alpine"
5+
- name: "(Install: Linux) Install NGINX Plus"
6+
import_tasks: install-plus-linux.yml
7+
when: ansible_os_family in nginx_plus_linux_families
68

7-
- import_tasks: setup-debian.yml
8-
when: ansible_os_family == "Debian"
9-
10-
- import_tasks: setup-freebsd.yml
11-
when: ansible_os_family == "FreeBSD"
12-
13-
- import_tasks: setup-redhat.yml
14-
when: ansible_os_family == "RedHat"
15-
16-
- import_tasks: setup-suse.yml
17-
when: ansible_os_family == "Suse"
18-
19-
- name: "(Install: All OSs) Install NGINX Plus"
20-
package:
21-
name: "nginx-plus{{ nginx_version | default('') }}"
22-
state: present
23-
notify: "(Handler: All OSs) Start NGINX"
9+
- name: "(Install: FreeBSD) Install NGINX Plus"
10+
import_tasks: install-plus-bsd.yml
11+
when: ansible_system in nginx_plus_bsd_systems

tasks/plus/setup-freebsd.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
---
2-
- import_tasks: setup-debian.yml
2+
- name: "(Setup: Debian/Ubuntu) Install Prerequisites"
3+
import_tasks: setup-debian.yml
34
when: ansible_os_family == "Debian"
5+
6+
- name: "(Setup: FreeBSD) Install Prerequisites"
7+
import_tasks: setup-freebsd.yml
8+
when: ansible_system == "FreeBSD"

tasks/prerequisites/setup-freebsd.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- name: "(Install: FreeBSD) Install Required Dependencies"
3+
block:
4+
5+
- name: "(Install: FreeBSD) Install Extra Package(s)"
6+
pkgng:
7+
name: "{{ nginx_freebsd_extra_packages }}"
8+
state: present
9+
when: nginx_bsd_install_packages|bool
10+
11+
- name: "(Install: FreeBSD) Install Extra Port(s)"
12+
portinstall:
13+
name: "{{ item }}"
14+
use_packages: "{{ nginx_bsd_portinstall_use_packages | default(omit) }}"
15+
state: present
16+
loop: "{{ nginx_freebsd_extra_packages }}"
17+
when: not nginx_bsd_install_packages|bool

0 commit comments

Comments
 (0)