Skip to content

Commit 6055dfd

Browse files
authored
Merge pull request #9 from nginxinc/threat-campaigns
Threat campaigns
2 parents 1b63a9b + 8dfd281 commit 6055dfd

11 files changed

+69
-10
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ This is a sample playbook file for using the role to install NGINX App Protect o
111111
# This option installs the latest NGINX App Protect signatures.
112112
app_protect_install_signatures: true
113113

114+
# The installation of NGINX App Protect can include a page of frequently-updated, high-accuracy signatures called Threat Campaigns.
115+
# This option installs the latest NGINX App Protect Threat Campaigns signatures.
116+
app_protect_install_threat_campaigns: true
117+
114118
# Creates basic configuration files and enables NGINX App Protect on the target host
115119
app_protect_configure: true
116120

defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ app_protect_selinux_enforcing: true
2222
# This option installs the latest NGINX App Protect signatures.
2323
app_protect_install_signatures: true
2424

25+
# The installation of NGINX App Protect can include a page of frequently-updated, high-accuracy signatures called Threat Campaigns.
26+
# This option installs the latest NGINX App Protect Threat Campaigns signatures.
27+
app_protect_install_threat_campaigns: false
28+
2529
# Creates basic configuration files and enables NGINX App Protect on the target host
2630
app_protect_configure: false
2731

molecule/default/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
vars:
55
app_protect_enable: true
66
app_protect_install_signatures: true
7+
app_protect_install_threat_campaigns: true
78
app_protect_configure: true
89
app_protect_security_policy_template_enable: true
910
security_policy_enforcement_mode: blocking

tasks/configure-selinux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
group: nginx
100100
mode: u=rwx,go=rx,g+s
101101
state: directory
102-
102+
103103
- name: "(Install: SELinux: Contexts) Apply contexts to log"
104104
command: restorecon -iRv /var/log/app_protect
105105
changed_when: false

tasks/delete-license.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
state: absent
1111
when: ansible_distribution != "Alpine"
1212

13-
- import_tasks: setup-debian.yml
13+
- import_tasks: setup-debian-repos.yml
1414
when: ansible_os_family == "Debian"
1515

16-
- import_tasks: setup-redhat.yml
16+
- import_tasks: setup-redhat-repos.yml
1717
when: ansible_os_family == "RedHat"

tasks/install-app-protect-linux.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
- name: "Remove NGINX App Protect"
2+
- name: "Setup NGINX App Protect Repositories"
33
block:
44

5-
- import_tasks: setup-debian.yml
5+
- import_tasks: setup-debian-repos.yml
66
when: ansible_os_family == "Debian"
77

8-
- import_tasks: setup-redhat.yml
8+
- import_tasks: setup-redhat-repos.yml
99
when: ansible_os_family == "RedHat"
1010

1111
when: app_protect_state != "absent"

tasks/install-threat-campaigns.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
- name: Get NGINX Plus version
3+
set_fact:
4+
key_value: "" # appeasing the linter
5+
nginx_plus_version: "{{ ansible_facts.packages['nginx-plus'] | map(attribute='version') | list | first | regex_search('^(\\d{1,3})') }}"
6+
when: "'nginx-plus' in ansible_facts.packages"
7+
8+
- name: Debug nginx plus version
9+
debug:
10+
msg: "nginx_plus_version {{ nginx_plus_version }}"
11+
verbosity: 2
12+
13+
- name: Fail if NGINX+ version preconditions fail
14+
assert:
15+
that:
16+
- nginx_plus_version is defined
17+
- nginx_plus_version | int >= 19
18+
fail_msg: >
19+
"'nginx_plus_version' release version must be a minimum of 19 for App Protect.
20+
Actual: {{ (nginx_plus_version is defined) | ternary(nginx_plus_version, 'NONE') }}"
21+
success_msg: "'nginx_plus_version' is {{ (nginx_plus_version is defined) | ternary(nginx_plus_version, 'NONE') }}"
22+
quiet: true
23+
24+
- name: "(Install: Linux) Install Latest NGINX App Protect Threat Campaigns"
25+
package:
26+
name: "app-protect-threat-campaigns"
27+
state: "{{ app_protect_state }}"
28+
notify: "(Handler: All OSs) Restart NGINX"

tasks/main.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,25 @@
4040
- import_tasks: keys/apt-key.yml
4141
when:
4242
- ansible_os_family == "Debian"
43-
- app_protect_install_signatures
43+
- app_protect_state != "absent"
44+
or app_protect_install_signatures
45+
or app_protect_install_threat_campaigns
4446
tags: nginx_aptkey
4547

4648
- import_tasks: keys/rpm-key.yml
4749
when:
4850
- ansible_os_family == "RedHat"
49-
- app_protect_install_signatures
51+
- app_protect_state != "absent"
52+
or app_protect_install_signatures
53+
or app_protect_install_threat_campaigns
5054
tags: nginx_rpmkey
5155

5256
- name: "(All OSs) Setup license"
5357
import_tasks: setup-license.yml
54-
when: app_protect_install_signatures
58+
when:
59+
- app_protect_state != "absent"
60+
or app_protect_install_signatures
61+
or app_protect_install_threat_campaigns
5562

5663
- name: "Install NGINX App Protect"
5764
import_tasks: install-app-protect.yml
@@ -60,6 +67,10 @@
6067
import_tasks: install-signatures.yml
6168
when: app_protect_install_signatures
6269

70+
- name: "NGINX App Protect Threat Campaigns"
71+
import_tasks: install-threat-campaigns.yml
72+
when: app_protect_install_threat_campaigns
73+
6374
- name: "Remove license"
6475
import_tasks: delete-license.yml
6576
when:
@@ -74,7 +85,7 @@
7485

7586
- name: "(Install: CentOS) Setup SELinux"
7687
include_tasks: "{{ role_path }}/tasks/configure-selinux.yml"
77-
when:
88+
when:
7889
- app_protect_selinux
7990
- ansible_os_family == "RedHat"
8091

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)