Skip to content
Snippets Groups Projects
Unverified Commit 1cbdd4cb authored by N's avatar N Committed by GitHub
Browse files

Merge pull request #69 from daks/map.jinja

Switching to map.jinja to define platform specific values
parents 0e697c67 6493d24a
No related branches found
No related tags found
No related merge requests found
{% from "haproxy/map.jinja" import haproxy with context %}
{% set config_file = salt['pillar.get']('haproxy:config_file_path', haproxy.config_file) %}
haproxy.config:
file.managed:
- name: {{ salt['pillar.get']('haproxy:config_file_path', '/etc/haproxy/haproxy.cfg') }}
- source: salt://haproxy/templates/haproxy.jinja
- name: {{ config_file }}
- source: {{ haproxy.config_file_source }}
- template: jinja
- user: root
{% if salt['grains.get']('os_family') == 'FreeBSD' %}
- group: wheel
{% else %}
- group: root
{% endif %}
- user: {{ haproxy.user }}
- group: {{ haproxy.group }}
- mode: 644
- require_in:
- service: haproxy.service
......@@ -16,5 +15,5 @@ haproxy.config:
- service: haproxy.service
{% if salt['pillar.get']('haproxy:overwrite', default=True) == False %}
- unless:
- test -e {{ salt['pillar.get']('haproxy:config_file_path', '/etc/haproxy/haproxy.cfg') }}
- test -e {{ config_file }}
{% endif %}
{% from "haproxy/map.jinja" import haproxy with context %}
haproxy.install:
pkg.installed:
- name: haproxy
- name: {{ haproxy.package }}
{% if salt['pillar.get']('haproxy:require') %}
- require:
{% for item in salt['pillar.get']('haproxy:require') %}
......
{% set haproxy = salt['grains.filter_by']({
'default': {
'package': 'haproxy',
'config_file': '/etc/haproxy/haproxy.cfg',
'config_file_source': 'salt://haproxy/templates/haproxy.jinja',
'user': 'root',
'group': 'root',
'service': 'haproxy',
},
'FreeBSD': {
'group': 'wheel',
},
}, merge=salt['pillar.get']('haproxy:lookup'), base='default') %}
{% from "haproxy/map.jinja" import haproxy with context %}
haproxy.service:
{% if salt['pillar.get']('haproxy:enable', True) %}
service.running:
- name: haproxy
- name: {{ haproxy.service }}
- enable: True
- reload: True
- require:
......
......@@ -3,9 +3,16 @@
#
haproxy:
# use lookup section to override 'map.jinja' values
#lookup:
#user: 'custom-user'
#group: 'custom-group'
# new setting to override configuration file path
#config_file: /etc/haproxy/haproxy.cfg
enabled: True
overwrite: True # Overwrite an existing config file if present (default behaviour unless set to false)
config_file_path: /etc/haproxy/haproxy.cfg
# old setting to override configuration file path, kept for compatibility
#config_file_path: /etc/haproxy/haproxy.cfg
global:
log:
- 127.0.0.1 local2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment