Skip to content

Commit 1cbdd4c

Browse files
Merge pull request #69 from daks/map.jinja
Switching to map.jinja to define platform specific values
2 parents 0e697c6 + 6493d24 commit 1cbdd4c

5 files changed

Lines changed: 36 additions & 12 deletions

File tree

haproxy/config.sls

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1+
{% from "haproxy/map.jinja" import haproxy with context %}
2+
3+
{% set config_file = salt['pillar.get']('haproxy:config_file_path', haproxy.config_file) %}
14
haproxy.config:
25
file.managed:
3-
- name: {{ salt['pillar.get']('haproxy:config_file_path', '/etc/haproxy/haproxy.cfg') }}
4-
- source: salt://haproxy/templates/haproxy.jinja
6+
- name: {{ config_file }}
7+
- source: {{ haproxy.config_file_source }}
58
- template: jinja
6-
- user: root
7-
{% if salt['grains.get']('os_family') == 'FreeBSD' %}
8-
- group: wheel
9-
{% else %}
10-
- group: root
11-
{% endif %}
9+
- user: {{ haproxy.user }}
10+
- group: {{ haproxy.group }}
1211
- mode: 644
1312
- require_in:
1413
- service: haproxy.service
1514
- watch_in:
1615
- service: haproxy.service
1716
{% if salt['pillar.get']('haproxy:overwrite', default=True) == False %}
1817
- unless:
19-
- test -e {{ salt['pillar.get']('haproxy:config_file_path', '/etc/haproxy/haproxy.cfg') }}
18+
- test -e {{ config_file }}
2019
{% endif %}

haproxy/install.sls

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
{% from "haproxy/map.jinja" import haproxy with context %}
2+
13
haproxy.install:
24
pkg.installed:
3-
- name: haproxy
5+
- name: {{ haproxy.package }}
46
{% if salt['pillar.get']('haproxy:require') %}
57
- require:
68
{% for item in salt['pillar.get']('haproxy:require') %}

haproxy/map.jinja

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% set haproxy = salt['grains.filter_by']({
2+
'default': {
3+
'package': 'haproxy',
4+
'config_file': '/etc/haproxy/haproxy.cfg',
5+
'config_file_source': 'salt://haproxy/templates/haproxy.jinja',
6+
'user': 'root',
7+
'group': 'root',
8+
'service': 'haproxy',
9+
},
10+
'FreeBSD': {
11+
'group': 'wheel',
12+
},
13+
}, merge=salt['pillar.get']('haproxy:lookup'), base='default') %}
14+

haproxy/service.sls

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
{% from "haproxy/map.jinja" import haproxy with context %}
2+
13
haproxy.service:
24
{% if salt['pillar.get']('haproxy:enable', True) %}
35
service.running:
4-
- name: haproxy
6+
- name: {{ haproxy.service }}
57
- enable: True
68
- reload: True
79
- require:

pillar.example

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
#
44

55
haproxy:
6+
# use lookup section to override 'map.jinja' values
7+
#lookup:
8+
#user: 'custom-user'
9+
#group: 'custom-group'
10+
# new setting to override configuration file path
11+
#config_file: /etc/haproxy/haproxy.cfg
612
enabled: True
713
overwrite: True # Overwrite an existing config file if present (default behaviour unless set to false)
8-
config_file_path: /etc/haproxy/haproxy.cfg
14+
# old setting to override configuration file path, kept for compatibility
15+
#config_file_path: /etc/haproxy/haproxy.cfg
916
global:
1017
log:
1118
- 127.0.0.1 local2

0 commit comments

Comments
 (0)