diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a1bead0f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.kitchen/ +Gemfile.lock diff --git a/consul/config.sls b/consul/config.sls index 44c39c91..036c592b 100644 --- a/consul/config.sls +++ b/consul/config.sls @@ -1,18 +1,24 @@ {%- from slspath + '/map.jinja' import consul with context -%} consul-config: - file.serialize: + file.managed: - name: /etc/consul.d/config.json - - formatter: json - - dataset: {{ consul.config }} - user: {{ consul.user }} - group: {{ consul.group }} - mode: 0640 + - source: salt://{{ slspath }}/files/template.json.jinja + - template: jinja + - context: + content: + {{ consul.config | yaml }} - require: - user: consul-user {%- if consul.service %} + - file: /usr/local/bin/consul - watch_in: - service: consul + - check_cmd: /usr/local/bin/consul validate + - tmp_ext: '.json' {%- endif %} {% for script in consul.scripts %} @@ -28,16 +34,24 @@ consul-script-install-{{ loop.index }}: {% endfor %} consul-script-config: - file.serialize: + file.managed: - name: /etc/consul.d/services.json - {% if consul.service != False %} - - watch_in: - - service: consul - {% endif %} - user: {{ consul.user }} - group: {{ consul.group }} + - mode: 0640 + - source: salt://{{ slspath }}/files/template.json.jinja + - template: jinja + - context: + content: + services: + {{ consul.register | yaml }} - require: - user: consul-user - - formatter: json - - dataset: - services: {{ consul.register }} + {% if consul.service != False %} + - file: /usr/local/bin/consul + - file: /etc/consul.d/config.json + - watch_in: + - service: consul + - check_cmd: /usr/local/bin/consul validate /etc/consul.d/config.json + - tmp_ext: '.json' + {% endif %} diff --git a/consul/files/template.json.jinja b/consul/files/template.json.jinja new file mode 100644 index 00000000..9e494f8e --- /dev/null +++ b/consul/files/template.json.jinja @@ -0,0 +1 @@ +{{ content | tojson(indent=2) }} diff --git a/pillar.example b/pillar.example index e465f426..2b06f261 100644 --- a/pillar.example +++ b/pillar.example @@ -6,7 +6,7 @@ consul: user: consul group: consul - version: 0.7.0 + version: 1.2.0 download_host: releases.hashicorp.com config: