From 6e3e2b94b9921e06c11579956c508e2124d6fa3e Mon Sep 17 00:00:00 2001 From: Chris Lundquist Date: Mon, 31 Oct 2016 20:30:48 +0000 Subject: [PATCH] [consul] allow rehoming --- consul/config.sls | 11 +++++++---- consul/files/config.json | 2 -- consul/files/services.json | 3 +-- consul/init.sls | 8 ++++---- consul/install.sls | 2 +- consul/map.jinja | 2 +- consul/service.sls | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/consul/config.sls b/consul/config.sls index 1525cde..1d079b5 100644 --- a/consul/config.sls +++ b/consul/config.sls @@ -1,9 +1,7 @@ -{% from "consul/map.jinja" import consul with context %} +{% from slspath+"/map.jinja" import consul with context %} consul-config: file.managed: - - source: salt://consul/files/config.json - - template: jinja - name: /etc/consul.d/config.json {% if consul.service != False %} - watch_in: @@ -13,6 +11,8 @@ consul-config: - group: consul - require: - user: consul + - contents: | + {{ consul.config | json }} {% for script in consul.scripts %} consul-script-install-{{ loop.index }}: @@ -27,7 +27,7 @@ consul-script-install-{{ loop.index }}: consul-script-config: file.managed: - - source: salt://consul/files/services.json + - source: salt://{{ slspath }}/files/services.json - name: /etc/consul.d/services.json - template: jinja {% if consul.service != False %} @@ -38,3 +38,6 @@ consul-script-config: - group: consul - require: - user: consul + - context: + register: | + {{ consul.register | json }} diff --git a/consul/files/config.json b/consul/files/config.json index 7e10c4c..e69de29 100644 --- a/consul/files/config.json +++ b/consul/files/config.json @@ -1,2 +0,0 @@ -{% from "consul/map.jinja" import consul with context %} -{{ consul.config | json}} diff --git a/consul/files/services.json b/consul/files/services.json index 546d3bb..4760311 100644 --- a/consul/files/services.json +++ b/consul/files/services.json @@ -1,4 +1,3 @@ -{% from "consul/map.jinja" import consul with context %} { - "services": {{ consul.register | json }} + "services": {{ register }} } diff --git a/consul/init.sls b/consul/init.sls index a04a2cd..4d31c6a 100644 --- a/consul/init.sls +++ b/consul/init.sls @@ -1,6 +1,6 @@ -{% from "consul/map.jinja" import consul with context %} +{% from slspath+"/map.jinja" import consul with context %} include: - - consul.install - - consul.config - - consul.service + - {{ slspath }}.install + - {{ slspath }}.config + - {{ slspath }}.service diff --git a/consul/install.sls b/consul/install.sls index ac9a389..1541800 100644 --- a/consul/install.sls +++ b/consul/install.sls @@ -1,4 +1,4 @@ -{% from "consul/map.jinja" import consul with context %} +{% from slspath+"/map.jinja" import consul with context %} consul-dep-unzip: pkg.installed: diff --git a/consul/map.jinja b/consul/map.jinja index b9efe6d..78bbf1e 100644 --- a/consul/map.jinja +++ b/consul/map.jinja @@ -1,4 +1,4 @@ -{% import_yaml "consul/defaults.yaml" as defaults %} +{% import_yaml slspath+"/defaults.yaml" as defaults %} {% set consul = salt['pillar.get']('consul', default=defaults.consul, merge=True) %} diff --git a/consul/service.sls b/consul/service.sls index fd8f183..3870954 100644 --- a/consul/service.sls +++ b/consul/service.sls @@ -1,17 +1,17 @@ -{%- from "consul/map.jinja" import consul with context -%} +{%- from slspath+"/map.jinja" import consul with context -%} consul-init-file: file.managed: {%- if salt['test.provider']('service') == 'systemd' %} - - source: salt://consul/files/consul.service + - source: salt://{{ slspath }}/files/consul.service - name: /etc/systemd/system/consul.service - mode: 0644 {%- elif salt['test.provider']('service') == 'upstart' %} - - source: salt://consul/files/consul.upstart + - source: salt://{{ slspath }}/files/consul.upstart - name: /etc/init/consul.conf - mode: 0644 {%- else %} - - source: salt://consul/files/consul.sysvinit + - source: salt://{{ slspath }}/files/consul.sysvinit - name: /etc/init.d/consul - mode: 0755 {%- endif %}