From 767274fd64d203a8f62d203168fbf1f5d50fdc74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bahad=C4=B1r=20Kandemir?= Date: Wed, 7 Oct 2015 22:02:53 +0300 Subject: [PATCH] Make config generic --- consul/defaults.yaml | 13 ++++++++----- consul/files/common.json | 7 ------- consul/files/config.json | 2 ++ consul/files/server.json | 5 ----- consul/init.sls | 22 +++------------------- pillar.example | 10 ++++++---- 6 files changed, 19 insertions(+), 40 deletions(-) delete mode 100644 consul/files/common.json create mode 100644 consul/files/config.json delete mode 100644 consul/files/server.json diff --git a/consul/defaults.yaml b/consul/defaults.yaml index 346bed0..77b3d3e 100644 --- a/consul/defaults.yaml +++ b/consul/defaults.yaml @@ -1,7 +1,10 @@ consul: - server: false - client: false service: false - token: "" - bootstrap: 1 - datacenter: "main" + config: + server: false + bind_addr: 0.0.0.0 + data_dir: /var/consul + ui_dir: /opt/consul/dist + enable_debug: false + log_level: info + encrypt: "" diff --git a/consul/files/common.json b/consul/files/common.json deleted file mode 100644 index a9c14b1..0000000 --- a/consul/files/common.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "data_dir": "/var/consul", - "ui_dir": "/opt/consul/dist", - "enable_debug": true, - "log_level": "info", - "encrypt": "{{ salt['pillar.get']('consul:token') }}" -} diff --git a/consul/files/config.json b/consul/files/config.json new file mode 100644 index 0000000..7e10c4c --- /dev/null +++ b/consul/files/config.json @@ -0,0 +1,2 @@ +{% from "consul/map.jinja" import consul with context %} +{{ consul.config | json}} diff --git a/consul/files/server.json b/consul/files/server.json deleted file mode 100644 index 70dd3ba..0000000 --- a/consul/files/server.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "server": true, - "bootstrap_expect": {{ salt['pillar.get']('consul:bootstrap') }}, - "datacenter": "{{ salt['pillar.get']('consul:datacenter') }}" -} diff --git a/consul/init.sls b/consul/init.sls index 1a0e40d..cb4e139 100644 --- a/consul/init.sls +++ b/consul/init.sls @@ -63,11 +63,11 @@ consul_data_dir: - user: consul - group: consul -consul_common_config: +consul_config: file.managed: - - source: salt://consul/files/common.json + - source: salt://consul/files/config.json - template: jinja - - name: /etc/consul.d/common.json + - name: /etc/consul.d/config.json {% if consul.service != False %} - watch_in: - service: consul @@ -77,22 +77,6 @@ consul_common_config: - require: - user: consul -{% if consul.server != False %} -consul_server_config: - file.managed: - - source: salt://consul/files/server.json - - name: /etc/consul.d/server.json - - template: jinja - {% if consul.service != False %} - - watch_in: - - service: consul - {% endif %} - - user: consul - - group: consul - - require: - - user: consul -{% endif %} - {% if consul.service != False %} consul_service: service.running: diff --git a/pillar.example b/pillar.example index a88c607..d2c8b4e 100644 --- a/pillar.example +++ b/pillar.example @@ -1,6 +1,8 @@ consul: - server: true service: true - token: "RIxqpNlOXqtr/j4BgvIMEw==" - bootstrap: 3 - datacenter: "eu" + config: + server: true + encrypt: "RIxqpNlOXqtr/j4BgvIMEw==" + bootstrap: 3 + datacenter: eu + bind_addr: 0.0.0.0