refactoring code to use map.jinja for config values
at the moment only Debian managed, FreeBSD exception still in state
This commit is contained in:
parent
0e697c67c9
commit
2b83ca0860
4 changed files with 25 additions and 7 deletions
|
@ -1,13 +1,16 @@
|
|||
{% 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
|
||||
- user: {{ haproxy.user }}
|
||||
{% if salt['grains.get']('os_family') == 'FreeBSD' %}
|
||||
- group: wheel
|
||||
{% else %}
|
||||
- group: root
|
||||
- group: {{ haproxy.group }}
|
||||
{% endif %}
|
||||
- mode: 644
|
||||
- require_in:
|
||||
|
@ -16,5 +19,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 %}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{% 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') %}
|
||||
|
|
11
haproxy/map.jinja
Normal file
11
haproxy/map.jinja
Normal file
|
@ -0,0 +1,11 @@
|
|||
{% 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')) %}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
{% 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:
|
||||
|
|
Loading…
Reference in a new issue