From eb6b073ad227641dc9ab865e0ce9dd64a759ceae Mon Sep 17 00:00:00 2001 From: Adam Bolte Date: Mon, 13 Jul 2015 19:14:51 +1000 Subject: [PATCH] Adjust ENABLED value based on pillar value. --- haproxy/service.sls | 16 +++++++++------- pillar.example | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/haproxy/service.sls b/haproxy/service.sls index 74ff3ff..4b36610 100644 --- a/haproxy/service.sls +++ b/haproxy/service.sls @@ -7,11 +7,13 @@ haproxy.service: - pkg: haproxy - watch: - file: haproxy.config - file.managed: + file.replace: - name: /etc/default/haproxy -#TODO: Add switch to turn the service on and off based on pillar configuration. - - source: salt://haproxy/files/haproxy-init-enable - - create: True - - user: "root" - - group: "root" - - mode: "0644" +{% if salt['pillar.get']('haproxy:enabled', True) %} + - pattern: ENABLED=0$ + - repl: ENABLED=1 +{% else %} + - pattern: ENABLED=1$ + - repl: ENABLED=0 +{% endif %} + - show_changes: True diff --git a/pillar.example b/pillar.example index 53a3911..f90debc 100644 --- a/pillar.example +++ b/pillar.example @@ -3,6 +3,7 @@ # haproxy: + enabled: True config_file_path: /etc/haproxy/haproxy.cfg global: stats: