|
2 | 2 | - name: Create additional configuration |
3 | 3 | template: |
4 | 4 | src: "hardening.conf.j2" |
5 | | - dest: "/etc/nginx/conf.d/90.hardening.conf" |
| 5 | + dest: "{{ nginx_configuration_dir }}/conf.d/90.hardening.conf" |
6 | 6 | mode: '0600' |
7 | | - owner: "root" |
8 | | - group: "root" |
| 7 | + owner: "{{ nginx_owner_user }}" |
| 8 | + group: "{{ nginx_owner_group }}" |
9 | 9 | notify: Restart nginx |
10 | 10 |
|
11 | 11 | - name: Change configuration in main nginx.conf |
12 | 12 | lineinfile: |
13 | | - dest: "/etc/nginx/nginx.conf" |
| 13 | + dest: "{{ nginx_configuration_dir }}/nginx.conf" |
14 | 14 | regexp: '^\s*server_tokens' |
15 | 15 | line: " server_tokens {{ nginx_server_tokens }};" |
16 | 16 | insertafter: "http {" |
17 | 17 | mode: '0640' |
18 | | - owner: "root" |
19 | | - group: "root" |
| 18 | + owner: "{{ nginx_owner_user }}" |
| 19 | + group: "{{ nginx_owner_group }}" |
20 | 20 | notify: Restart nginx |
21 | 21 |
|
22 | 22 | - name: Change ssl_protocols in main nginx.conf |
23 | 23 | lineinfile: |
24 | | - dest: "/etc/nginx/nginx.conf" |
| 24 | + dest: "{{ nginx_configuration_dir }}/nginx.conf" |
25 | 25 | regexp: '^\s*ssl_protocols' |
26 | 26 | line: " ssl_protocols {{ nginx_ssl_protocols }};" |
27 | 27 | insertafter: "http {" |
28 | 28 | mode: '0640' |
29 | | - owner: "root" |
30 | | - group: "root" |
| 29 | + owner: "{{ nginx_owner_user }}" |
| 30 | + group: "{{ nginx_owner_group }}" |
31 | 31 | notify: Restart nginx |
32 | 32 |
|
33 | 33 | - name: Change ssl_prefer_server_ciphers in main nginx.conf |
34 | 34 | lineinfile: |
35 | | - dest: "/etc/nginx/nginx.conf" |
| 35 | + dest: "{{ nginx_configuration_dir }}/nginx.conf" |
36 | 36 | regexp: '^\s*ssl_prefer_server_ciphers' |
37 | 37 | line: " ssl_prefer_server_ciphers {{ nginx_ssl_prefer_server_ciphers }};" |
38 | 38 | insertafter: "http {" |
39 | 39 | mode: '0640' |
40 | | - owner: "root" |
41 | | - group: "root" |
| 40 | + owner: "{{ nginx_owner_user }}" |
| 41 | + group: "{{ nginx_owner_group }}" |
42 | 42 | notify: Restart nginx |
43 | 43 |
|
44 | 44 | - name: Change client_max_body_size in main nginx.conf |
45 | 45 | lineinfile: |
46 | | - dest: "/etc/nginx/nginx.conf" |
| 46 | + dest: "{{ nginx_configuration_dir }}/nginx.conf" |
47 | 47 | regexp: '^\s*client_max_body_size' |
48 | 48 | line: " client_max_body_size {{ nginx_client_max_body_size }};" |
49 | 49 | insertafter: "http {" |
50 | 50 | mode: '0640' |
51 | | - owner: "root" |
52 | | - group: "root" |
| 51 | + owner: "{{ nginx_owner_user }}" |
| 52 | + group: "{{ nginx_owner_group }}" |
53 | 53 | notify: Restart nginx |
54 | 54 |
|
55 | 55 | - name: Change client_body_buffer_size in main nginx.conf |
56 | 56 | lineinfile: |
57 | | - dest: "/etc/nginx/nginx.conf" |
| 57 | + dest: "{{ nginx_configuration_dir }}/nginx.conf" |
58 | 58 | regexp: '^\s*client_body_buffer_size' |
59 | 59 | line: " client_body_buffer_size {{ nginx_client_body_buffer_size }};" |
60 | 60 | insertafter: "http {" |
61 | 61 | mode: '0640' |
62 | | - owner: "root" |
63 | | - group: "root" |
| 62 | + owner: "{{ nginx_owner_user }}" |
| 63 | + group: "{{ nginx_owner_group }}" |
64 | 64 | notify: Restart nginx |
65 | 65 |
|
66 | 66 | - name: Change keepalive_timeout in main nginx.conf |
67 | 67 | lineinfile: |
68 | | - dest: "/etc/nginx/nginx.conf" |
| 68 | + dest: "{{ nginx_configuration_dir }}/nginx.conf" |
69 | 69 | regexp: '^\s*keepalive_timeout' |
70 | 70 | line: " keepalive_timeout {{ nginx_keepalive_timeout }};" |
71 | 71 | insertafter: "http {" |
72 | 72 | mode: '0640' |
73 | | - owner: "root" |
74 | | - group: "root" |
| 73 | + owner: "{{ nginx_owner_user }}" |
| 74 | + group: "{{ nginx_owner_group }}" |
75 | 75 | notify: Restart nginx |
76 | 76 |
|
77 | 77 | - name: Remove default.conf |
|
81 | 81 | when: nginx_remove_default_site |
82 | 82 | notify: Restart nginx |
83 | 83 | loop: |
84 | | - - "/etc/nginx/conf.d/default.conf" |
85 | | - - "/etc/nginx/sites-enabled/default" |
| 84 | + - "{{ nginx_configuration_dir }}/conf.d/default.conf" |
| 85 | + - "{{ nginx_configuration_dir }}/sites-enabled/default" |
86 | 86 |
|
87 | 87 | - name: Generate dh group |
88 | 88 | openssl_dhparam: |
89 | | - path: "/etc/nginx/dh{{ nginx_dh_size }}.pem" |
| 89 | + path: "{{ nginx_configuration_dir }}/dh{{ nginx_dh_size }}.pem" |
90 | 90 | size: "{{ nginx_dh_size }}" |
91 | 91 | mode: '0640' |
92 | | - owner: "root" |
93 | | - group: "root" |
| 92 | + owner: "{{ nginx_owner_user }}" |
| 93 | + group: "{{ nginx_owner_group }}" |
94 | 94 | notify: Restart nginx |
0 commit comments