From 6cb486dbd290c91bbdbf00fd0061efaedbef4dea Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Sat, 23 Jan 2021 07:04:12 -0700 Subject: [PATCH 1/2] fix(snippets): ignore servers or snippets when undefined nginx.servers_config wants a lightened copy of the nginx map to render as json; but, when it was trying to remove the servers and snippets keys from the map it assumed their presence, causing a KeyError if they were not present by its use of .pop(). While wrapping these in an "if" clause would likely be more correct, along with replacing .pop() with del (if jinja even supports that) the simplest change here is to just specify a default value for .pop(), which obviates the KeyError. Fixes #274 --- nginx/servers_config.sls | 4 ++-- nginx/snippets.sls | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nginx/servers_config.sls b/nginx/servers_config.sls index 5dd11a9..6652d64 100644 --- a/nginx/servers_config.sls +++ b/nginx/servers_config.sls @@ -10,8 +10,8 @@ {% set server_states = [] %} {#- _nginx is a lightened copy of nginx map intended to passed in templates #} {%- set _nginx = nginx.copy() %} -{%- do _nginx.pop('snippets') %} -{%- do _nginx.pop('servers') %} +{%- do _nginx.pop('snippets') if nginx.snippets is defined %} +{%- do _nginx.pop('servers') if nginx.servers is defined %} # Simple path concatenation. # Needs work to make this function on windows. diff --git a/nginx/snippets.sls b/nginx/snippets.sls index d09ba36..f19905b 100644 --- a/nginx/snippets.sls +++ b/nginx/snippets.sls @@ -8,8 +8,8 @@ {#- _nginx is a lightened copy of nginx map intended to passed in templates #} {%- set _nginx = nginx.copy() %} -{%- do _nginx.pop('snippets') %} -{%- do _nginx.pop('servers') %} +{%- do _nginx.pop('snippets') if nginx.snippets is defined %} +{%- do _nginx.pop('servers') if nginx.servers is defined %} nginx_snippets_dir: file.directory: From 0cd7c7b20528ce9fbd4f8991a365415a3093546d Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 14 Jun 2021 18:31:06 +0100 Subject: [PATCH 2/2] fix(certificates): ensure `openssl` installed before `cmd.run` Fix failure highlighted on OpenSUSE Tumbleweed, where the `cmd.run` runs before the `pkg.installed`: * https://gitlab.com/saltstack-formulas/nginx-formula/-/jobs/1345325819#L2830 --- nginx/certificates.sls | 1 + 1 file changed, 1 insertion(+) diff --git a/nginx/certificates.sls b/nginx/certificates.sls index 2a8330b..8781045 100644 --- a/nginx/certificates.sls +++ b/nginx/certificates.sls @@ -30,6 +30,7 @@ generate_nginx_dhparam_{{ dh_param }}_key: - creates: {{ certificates_path }}/{{ dh_param }} - require: - file: prepare_certificates_path_dir + - pkg: generate_nginx_dhparam_{{ dh_param }}_key - watch_in: - service: nginx_service {%- endif %}