Skip to content

Commit 6c4f78b

Browse files
committed
refactor(pillar): namespace defaults to meta-state name
This might be useful if one wants to use this formula with a (renamed) fork within the same environment. Note this also permits to override pillar namespace by defining '{meta-state name}:pillar:namespace: str'.
1 parent 4f117cd commit 6c4f78b

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

nginx/certificates.sls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{%- set tplroot = tpldir.split('/')[0] %}
2-
{%- from tplroot ~ '/map.jinja' import nginx with context %}
2+
{%- from tplroot ~ '/map.jinja' import nginx, pillar_namespace with context %}
33
44
include:
55
- {{ tplroot }}.service
@@ -14,7 +14,7 @@ prepare_certificates_path_dir:
1414
create_nginx_dhparam_{{ dh_param }}_key:
1515
file.managed:
1616
- name: {{ nginx.certificates_path }}/{{ dh_param }}
17-
- contents_pillar: nginx:dh_param:{{ dh_param }}
17+
- contents_pillar: {{ pillar_namespace }}:dh_param:{{ dh_param }}
1818
- makedirs: True
1919
- require:
2020
- file: prepare_certificates_path_dir
@@ -44,7 +44,7 @@ nginx_{{ domain }}_ssl_certificate:
4444
{% if domain in nginx.certificates and 'public_cert_pillar' in nginx.certificates[domain] %}
4545
- contents_pillar: {{ nginx.certificates[domain].public_cert_pillar }}
4646
{% else %}
47-
- contents_pillar: nginx:certificates:{{ domain }}:public_cert
47+
- contents_pillar: {{ pillar_namespace }}:certificates:{{ domain }}:public_cert
4848
{% endif %}
4949
- watch_in:
5050
- service: nginx_service
@@ -58,7 +58,7 @@ nginx_{{ domain }}_ssl_key:
5858
{% if 'private_key_pillar' in nginx.certificates[domain] %}
5959
- contents_pillar: {{ nginx.certificates[domain].private_key_pillar }}
6060
{% else %}
61-
- contents_pillar: nginx:certificates:{{ domain }}:private_key
61+
- contents_pillar: {{ pillar_namespace }}:certificates:{{ domain }}:private_key
6262
{% endif %}
6363
- watch_in:
6464
- service: nginx_service

nginx/map.jinja

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
{% endfor %}
55
{% endmacro %}
66

7-
{% set nginx = salt['pillar.get']('nginx', {
7+
{%- set tplroot = tpldir.split('/')[0] %}
8+
{% set pillar_namespace = salt['pillar.get']('{}:pillar:namespace'.format(tplroot), tplroot) %}
9+
{% set nginx = salt['pillar.get'](pillar_namespace, {
810
'lookup': salt['grains.filter_by']({
911
'Debian': {
1012
'package': 'nginx',

pillar.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,7 @@ nginx:
357357
- alt_nginx.service
358358
nginx_snippet_file_managed:
359359
- alt_server.conf
360+
361+
# Configure formula pillar namespace
362+
pillar:
363+
namespace: nginx

0 commit comments

Comments
 (0)