Skip to content

Commit b396b24

Browse files
committed
feat(config): validate config before applying
1 parent 63d32a4 commit b396b24

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

nginx/config.sls

+3
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ nginx_config:
3131
- context:
3232
config: {{ nginx.server.config|json(sort_keys=False) }}
3333
{% endif %}
34+
{% if nginx.check_config_before_apply %}
35+
- check_cmd: /usr/sbin/nginx -t -c
36+
{% endif %}

nginx/map.jinja

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
'install_from_ppa': False,
113113
'install_from_repo': False,
114114
'install_from_phusionpassenger': False,
115+
'check_config_before_apply': False,
115116
'ppa_version': 'stable',
116117
'source_version': '1.10.0',
117118
'source_hash': '8ed647c3dd65bc4ced03b0e0f6bf9e633eff6b01bac772bcf97077d58bc2be4d',

pillar.example

+11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ nginx:
2828
source_version: '1.10.0'
2929
source_hash: ''
3030

31+
# Check the configuration before applying:
32+
# To prevent applying a configuration that might break nginx, set this
33+
# parameter to true so the configuration is checked BEFORE applying. If
34+
# the check fails, the state will fail and it won't be deployed.
35+
# CAVEAT: As the configuration file is created in a temp dir, it can't
36+
# have relative references or it will fail to check. You'll need to
37+
# specify full paths where required (ie, `include`, `load_module`,
38+
# `snippets`, etc.0
39+
# Defaults to false
40+
check_config_before_apply: false
41+
3142
# These are usually set by grains in map.jinja
3243
# Typically you can comment these out.
3344
lookup:

0 commit comments

Comments
 (0)