Skip to content

Commit 2b83ca0

Browse files
committed
refactoring code to use map.jinja for config values
at the moment only Debian managed, FreeBSD exception still in state
1 parent 0e697c6 commit 2b83ca0

4 files changed

Lines changed: 25 additions & 7 deletions

File tree

haproxy/config.sls

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
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
9+
- user: {{ haproxy.user }}
710
{% if salt['grains.get']('os_family') == 'FreeBSD' %}
811
- group: wheel
912
{% else %}
10-
- group: root
13+
- group: {{ haproxy.group }}
1114
{% endif %}
1215
- mode: 644
1316
- require_in:
@@ -16,5 +19,5 @@ haproxy.config:
1619
- service: haproxy.service
1720
{% if salt['pillar.get']('haproxy:overwrite', default=True) == False %}
1821
- unless:
19-
- test -e {{ salt['pillar.get']('haproxy:config_file_path', '/etc/haproxy/haproxy.cfg') }}
22+
- test -e {{ config_file }}
2023
{% 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% set haproxy = salt['grains.filter_by']({
2+
'Debian': {
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+
}, merge=salt['pillar.get']('haproxy:lookup')) %}
11+

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:

0 commit comments

Comments
 (0)