Skip to content
Snippets Groups Projects
Commit 2b83ca08 authored by Eric Veiras Galisson's avatar Eric Veiras Galisson
Browse files

refactoring code to use map.jinja for config values

at the moment only Debian managed, FreeBSD exception still in state
parent 0e697c67
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: haproxy.config:
file.managed: file.managed:
- name: {{ salt['pillar.get']('haproxy:config_file_path', '/etc/haproxy/haproxy.cfg') }} - name: {{ config_file }}
- source: salt://haproxy/templates/haproxy.jinja - source: {{ haproxy.config_file_source }}
- template: jinja - template: jinja
- user: root - user: {{ haproxy.user }}
{% if salt['grains.get']('os_family') == 'FreeBSD' %} {% if salt['grains.get']('os_family') == 'FreeBSD' %}
- group: wheel - group: wheel
{% else %} {% else %}
- group: root - group: {{ haproxy.group }}
{% endif %} {% endif %}
- mode: 644 - mode: 644
- require_in: - require_in:
...@@ -16,5 +19,5 @@ haproxy.config: ...@@ -16,5 +19,5 @@ haproxy.config:
- service: haproxy.service - service: haproxy.service
{% if salt['pillar.get']('haproxy:overwrite', default=True) == False %} {% if salt['pillar.get']('haproxy:overwrite', default=True) == False %}
- unless: - unless:
- test -e {{ salt['pillar.get']('haproxy:config_file_path', '/etc/haproxy/haproxy.cfg') }} - test -e {{ config_file }}
{% endif %} {% endif %}
{% from "haproxy/map.jinja" import haproxy with context %}
haproxy.install: haproxy.install:
pkg.installed: pkg.installed:
- name: haproxy - name: {{ haproxy.package }}
{% if salt['pillar.get']('haproxy:require') %} {% if salt['pillar.get']('haproxy:require') %}
- require: - require:
{% for item in salt['pillar.get']('haproxy:require') %} {% for item in salt['pillar.get']('haproxy:require') %}
......
{% set haproxy = salt['grains.filter_by']({
'Debian': {
'package': 'haproxy',
'config_file': '/etc/haproxy/haproxy.cfg',
'config_file_source': 'salt://haproxy/templates/haproxy.jinja',
'user': 'root',
'group': 'root',
'service': 'haproxy',
},
}, merge=salt['pillar.get']('haproxy:lookup')) %}
{% from "haproxy/map.jinja" import haproxy with context %}
haproxy.service: haproxy.service:
{% if salt['pillar.get']('haproxy:enable', True) %} {% if salt['pillar.get']('haproxy:enable', True) %}
service.running: service.running:
- name: haproxy - name: {{ haproxy.service }}
- enable: True - enable: True
- reload: True - reload: True
- require: - require:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment