Skip to content

Commit 028f954

Browse files
authored
Make backup parameter optional (#205)
1 parent 5105b27 commit 028f954

File tree

8 files changed

+39
-11
lines changed

8 files changed

+39
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ BREAKING CHANGES:
66

77
Remove parameters deprecated in release `0.4.0`. To recap, these are `nginx_config_main_upload_*`, `nginx_config_upload_html_*`, and `nginx_config_stream_upload_*`. Use `nginx_config_upload` instead.
88

9+
FEATURES:
10+
11+
Add `backup` variable to template and upload parameters. Set to `false` if you don't want to keep backups of your previous NGINX config files.
12+
913
## 0.4.2 (October 28, 2021)
1014

1115
BUG FIXES:

defaults/main/template.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ nginx_config_html_demo_template:
66
html_file_name: index.html
77
html_file_location: /usr/share/nginx/html
88
web_server_name: Default
9+
backup: true
910

1011
# Enable creating dynamic templated NGINX configuration files.
1112
# Defaults are the values found in a fresh NGINX installation.
@@ -14,6 +15,7 @@ nginx_config_main_template_enable: false
1415
nginx_config_main_template:
1516
template_file: nginx.conf.j2
1617
deployment_location: /etc/nginx/nginx.conf
18+
backup: true
1719
config:
1820
main: # Configure NGINX main core directives
1921
load_module: modules/ngx_http_js_module.so # String or a list of strings
@@ -78,6 +80,7 @@ nginx_config_http_template_enable: false
7880
nginx_config_http_template:
7981
- template_file: http/default.conf.j2
8082
deployment_location: /etc/nginx/conf.d/default.conf
83+
backup: true
8184
config:
8285
upstreams: # Configure NGINX upstreams
8386
- name: backend # Required
@@ -672,6 +675,7 @@ nginx_config_http_template:
672675
nginx_config_status_enable: false
673676
nginx_config_status_template_file: http/status.conf.j2
674677
nginx_config_status_file_location: /etc/nginx/conf.d/status.conf
678+
nginx_config_status_backup: true
675679
nginx_config_status_port: 8080 # Optional -- Defaults to 8080
676680
nginx_config_status_access_log: # Optional -- Set to 'false' and remove/comment nested variables to disable access log
677681
location: /var/log/nginx/access.log # Required
@@ -687,6 +691,7 @@ nginx_config_status_deny: # Optional
687691
nginx_config_rest_api_enable: false
688692
nginx_config_rest_api_template_file: http/api.conf.j2
689693
nginx_config_rest_api_file_location: /etc/nginx/conf.d/api.conf
694+
nginx_config_rest_api_backup: true
690695
nginx_config_rest_api_port: 8080 # Optional-- Defaults to 8080
691696
nginx_config_rest_api_write: false # Optional
692697
nginx_config_rest_api_access_log: # Optional -- Set to 'false' and remove/comment nested variables to disable access log
@@ -710,6 +715,7 @@ nginx_config_stream_template:
710715
- template_file: stream/default.conf.j2
711716
conf_file_name: default.conf
712717
conf_file_location: /etc/nginx/conf.d/stream/
718+
backup: true
713719
network_streams:
714720
- listen:
715721
- ip: 0.0.0.0 # Wrap in square brackets for IPv6 addresses

defaults/main/upload.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ nginx_config_upload_enable: false
77
nginx_config_upload:
88
- src: config/snippets/ # You can optionally also include the specific file name
99
dest: /etc/nginx/snippets # You can optionally also include the specific desired file name
10+
backup: true
1011
# Upload HTML files.
1112
nginx_config_upload_html_enable: false
1213
nginx_config_upload_html:
1314
- src: www/index.html
1415
dest: /usr/share/nginx/html
16+
backup: true
1517
# Upload SSL certificates and keys.
1618
nginx_config_upload_ssl_enable: false
1719
nginx_config_upload_ssl_crt:
1820
- src: ssl/certs/
1921
dest: /etc/ssl/certs
22+
backup: true
2023
nginx_config_upload_ssl_key:
2124
- src: ssl/private/
2225
dest: /etc/ssl/private
26+
backup: true

molecule/default/converge.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
nginx_config_upload_ssl_crt:
1717
- src: ../common/files/ssl/molecule.crt
1818
dest: /etc/ssl/certs
19+
backup: true
1920
nginx_config_upload_ssl_key:
2021
- src: ../common/files/ssl/molecule.key
2122
dest: /etc/ssl/private
23+
backup: true
2224

2325
nginx_config_main_template_enable: true
2426
nginx_config_main_template:
2527
template_file: nginx.conf.j2
2628
deployment_location: /etc/nginx/nginx.conf
29+
backup: true
2730
config:
2831
main:
2932
load_module:
@@ -75,14 +78,16 @@
7578
- /etc/nginx/conf.d/stream/*.conf
7679

7780
nginx_config_status_enable: true
81+
nginx_config_status_backup: true
7882
nginx_config_status_port: 8080
7983
nginx_config_status_access_log:
8084
path: /var/log/nginx/access.log
8185
format: main
8286

8387
nginx_config_http_template_enable: true
8488
nginx_config_http_template:
85-
- config:
89+
- backup: true
90+
config:
8691
upstreams:
8792
- name: frontend_servers
8893
zone:
@@ -661,17 +666,20 @@
661666
- template_file: www/index.html.j2
662667
html_file_name: frontend_index.html
663668
html_file_location: /usr/share/nginx/html
669+
backup: true
664670
web_server_name: Frontend
665671
- template_file: www/index.html.j2
666672
html_file_name: backend_index.html
667673
html_file_location: /usr/share/nginx/html
674+
backup: true
668675
web_server_name: Backend
669676

670677
nginx_config_stream_template_enable: true
671678
nginx_config_stream_template:
672679
- template_file: stream/default.conf.j2
673680
conf_file_name: stream_default.conf
674681
conf_file_location: /etc/nginx/conf.d/stream
682+
backup: true
675683
network_streams:
676684
- listen:
677685
- ip: 0.0.0.0

molecule/plus/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
- /etc/nginx/conf.d/stream/*.conf
4343

4444
nginx_config_rest_api_enable: true
45+
nginx_config_rest_api_backup: true
4546
nginx_config_rest_api_write: true
4647
nginx_config_rest_api_access_log:
4748
path: /var/log/nginx/access.log

molecule/stable_push/converge.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@
1313
nginx_config_upload:
1414
- src: ../common/files/snippets/location_snippet.conf
1515
dest: /etc/nginx/snippets
16+
backup: true
1617
- src: ../common/files/http/
1718
dest: /etc/nginx/conf.d
19+
backup: true
1820
nginx_config_upload_html_enable: true
1921
nginx_config_upload_html:
2022
- src: ../common/files/www/index.html
2123
dest: /usr/share/nginx/html
24+
backup: true
2225
nginx_config_upload_ssl_enable: true
2326
nginx_config_upload_ssl_crt:
2427
- src: ../common/files/ssl/molecule.crt
2528
dest: /etc/ssl/certs
29+
backup: true
2630
nginx_config_upload_ssl_key:
2731
- src: ../common/files/ssl/molecule.key
2832
dest: /etc/ssl/private
33+
backup: true

tasks/config/template-config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
template:
1212
src: "{{ item.template_file | default('www/index.html.j2') }}"
1313
dest: "{{ item.html_file_location | default('/usr/share/nginx/html') }}/{{ item.html_file_name | default('index.html') }}"
14-
backup: true
14+
backup: "{{ item.backup | default(true) }}"
1515
mode: 0644
1616
loop: "{{ nginx_config_html_demo_template }}"
1717
when: nginx_config_html_demo_template_enable | bool
@@ -38,7 +38,7 @@
3838
template:
3939
src: "{{ nginx_config_main_template.template_file | default('nginx.conf.j2') }}"
4040
dest: "{{ nginx_config_main_template.deployment_location | default('/etc/nginx/nginx.conf') }}"
41-
backup: true
41+
backup: "{{ nginx_config_main_template.backup | default(true) }}"
4242
mode: 0644
4343
when: nginx_config_main_template_enable | bool
4444
notify: (Handler - NGINX Config) Run NGINX
@@ -67,7 +67,7 @@
6767
template:
6868
src: "{{ item.template_file | default('http/default.conf.j2') }}"
6969
dest: "{{ item.deployment_location | default('/etc/nginx/conf.d/default.conf') }}"
70-
backup: true
70+
backup: "{{ item.backup | default(true) }}"
7171
mode: 0644
7272
loop: "{{ nginx_config_http_template }}"
7373
when: nginx_config_http_template_enable | bool
@@ -77,7 +77,7 @@
7777
template:
7878
src: "{{ nginx_config_status_template_file | default('http/status.conf.j2') }}"
7979
dest: "{{ nginx_config_status_file_location | default('/etc/nginx/conf.d/status.conf') }}"
80-
backup: true
80+
backup: "{{ nginx_config_status_backup | default(true) }}"
8181
mode: 0644
8282
notify: (Handler - NGINX Config) Run NGINX
8383
when: nginx_config_status_enable | bool
@@ -86,7 +86,7 @@
8686
template:
8787
src: "{{ nginx_config_rest_api_template_file | default('http/api.conf.j2') }}"
8888
dest: "{{ nginx_config_rest_api_file_location | default('/etc/nginx/conf.d/api.conf') }}"
89-
backup: true
89+
backup: "{{ nginx_config_rest_api_backup | default(true) }}"
9090
mode: 0644
9191
notify: (Handler - NGINX Config) Run NGINX
9292
when: nginx_config_rest_api_enable | bool
@@ -103,7 +103,7 @@
103103
template:
104104
src: "{{ item.template_file | default('stream/default.conf.j2') }}"
105105
dest: "{{ item.conf_file_location | default('/etc/nginx/conf.d/stream') }}/{{ item.conf_file_name | default('default.conf') }}"
106-
backup: true
106+
backup: "{{ item.backup | default(true) }}"
107107
mode: 0644
108108
loop: "{{ nginx_config_stream_template }}"
109109
notify: (Handler - NGINX Config) Run NGINX

tasks/config/upload-config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
copy:
1313
src: "{{ item.src }}"
1414
dest: "{{ item.dest | default('/etc/nginx/') }}"
15-
backup: true
15+
backup: "{{ item.backup | default(true) }}"
1616
mode: 0644
1717
loop: "{{ nginx_config_upload }}"
1818
notify: (Handler - NGINX Config) Run NGINX
@@ -31,7 +31,7 @@
3131
copy:
3232
src: "{{ item.src }}"
3333
dest: "{{ item.dest | default('/usr/share/nginx/html') }}"
34-
backup: true
34+
backup: "{{ item.backup | default(true) }}"
3535
mode: 0644
3636
loop: "{{ nginx_config_upload_html }}"
3737
notify: (Handler - NGINX Config) Run NGINX
@@ -50,15 +50,15 @@
5050
copy:
5151
src: "{{ item.src }}"
5252
dest: "{{ item.dest | default('/etc/ssl/certs') }}"
53-
backup: true
53+
backup: "{{ item.backup | default(true) }}"
5454
mode: 0640
5555
loop: "{{ nginx_config_upload_ssl_crt }}"
5656

5757
- name: Upload NGINX SSL keys
5858
copy:
5959
src: "{{ item.src }}"
6060
dest: "{{ item.dest | default('/etc/ssl/private') }}"
61-
backup: true
61+
backup: "{{ item.backup | default(true) }}"
6262
mode: 0640
6363
loop: "{{ nginx_config_upload_ssl_key }}"
6464
no_log: true

0 commit comments

Comments
 (0)