File tree 2 files changed +20
-9
lines changed
2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 2
2
---
3
3
# Tasks for compiling Modsecurity3 and installing OWASP CRS v3
4
4
5
- - name : Set nginx_modules_location if not already set
5
+ - name : Get Nginx modules location
6
+ shell : nginx -V 2>&1 | grep "configure arguments:" | sed -e 's/.*--modules-path=\([^ ]*\).*/\1/'
7
+ register : _nginx_modules_location
8
+ changed_when : false
9
+ when : nginx_modules_location is not defined
10
+
11
+ - name : Set variable nginx_modules_location
6
12
set_fact :
7
- nginx_modules_location : " {{ nginx_conf_dir }}/modules "
13
+ nginx_modules_location : " {{ _nginx_modules_location.stdout }}"
8
14
when : nginx_modules_location is not defined
9
15
10
16
- name : Clear previous compilation
96
102
- name : Copy Modsecurity-nginx module to Nginx modules folder
97
103
copy :
98
104
src : " ~/Nginx/nginx-{{ nginx_modsec3_crs3_nginx_version }}/objs/ngx_http_modsecurity_module.so"
99
- dest : " {{ nginx_modules_location }}"
105
+ dest : " {{ nginx_modules_location }}/ngx_http_modsecurity_module.so "
100
106
remote_src : yes
101
107
when : not modsec3_nginx_present or nginx_modsec3_crs3_force_compile
102
108
Original file line number Diff line number Diff line change 33
33
state : present
34
34
when : ansible_os_family == "Redhat"
35
35
36
- - name : run Nginx selinux tasks
36
+ - name : Run Nginx SElinux tasks
37
37
include_role :
38
38
name : jdauphant.nginx
39
39
tasks_from : selinux.yml
40
40
allow_duplicates : yes
41
41
when : ansible_selinux and ansible_selinux.status == "enabled"
42
42
43
- - name : run Nginx nginx offical repo tasks
43
+ - name : Run Nginx official repo tasks
44
44
include_role :
45
45
name : jdauphant.nginx
46
46
tasks_from : nginx-official-repo.yml
47
47
allow_duplicates : yes
48
48
when : nginx_official_repo == True
49
49
50
- - name : run Nginx install packages tasks
50
+ - name : Run Nginx install packages tasks
51
51
include_role :
52
52
name : jdauphant.nginx
53
53
tasks_from : installation.packages.yml
62
62
set_fact :
63
63
nginx_modsec3_crs3_nginx_version : " {{ ansible_facts.packages.nginx[0].version.split('-')[0] }}"
64
64
65
- - name : Set nginx_conf_dir if not already set
65
+ - name : Get Nginx conf location
66
+ shell : dirname $(nginx -V 2>&1 | grep "configure arguments:" | sed -e 's/.*--conf-path=\([^ ]*\).*/\1/')
67
+ register : _nginx_conf_location
68
+ changed_when : false
69
+ when : nginx_conf_dir is not defined
70
+
71
+ - name : Set variable nginx_conf_dir
66
72
set_fact :
67
- nginx_conf_dir : " /etc/nginx "
73
+ nginx_conf_dir : " {{ _nginx_conf_location.stdout }} "
68
74
when : nginx_conf_dir is not defined
69
75
70
76
- name : Check if ModSecurity3 is present
111
117
name : " {{ installed.stdout_lines }}"
112
118
state : absent
113
119
when : installed is defined and (nginx_modsec3_crs3_keep is undefined or not nginx_modsec3_crs3_keep)
114
-
You can’t perform that action at this time.
0 commit comments