2016-10-31 16:30:48 -04:00
|
|
|
{%- from slspath+"/map.jinja" import consul with context -%}
|
2015-10-22 15:29:19 -04:00
|
|
|
|
2017-11-28 05:16:19 -05:00
|
|
|
consul-init-env:
|
|
|
|
file.managed:
|
|
|
|
{%- if grains['os_family'] == 'Debian' %}
|
|
|
|
- name: /etc/default/consul
|
|
|
|
{%- else %}
|
|
|
|
- name: /etc/sysconfig/consul
|
|
|
|
- makedirs: True
|
|
|
|
{%- endif %}
|
|
|
|
- user: root
|
|
|
|
- group: root
|
|
|
|
- mode: 0644
|
|
|
|
- contents:
|
|
|
|
- CONSUL_USER={{ consul.user }}
|
|
|
|
- CONSUL_GROUP={{ consul.group }}
|
|
|
|
|
2016-10-24 06:43:23 -04:00
|
|
|
consul-init-file:
|
2015-10-22 15:29:19 -04:00
|
|
|
file.managed:
|
2016-10-24 06:43:23 -04:00
|
|
|
{%- if salt['test.provider']('service') == 'systemd' %}
|
2016-10-31 16:30:48 -04:00
|
|
|
- source: salt://{{ slspath }}/files/consul.service
|
2016-04-22 06:40:14 -04:00
|
|
|
- name: /etc/systemd/system/consul.service
|
2017-11-28 05:16:19 -05:00
|
|
|
- template: jinja
|
|
|
|
- context:
|
|
|
|
user: {{ consul.user }}
|
|
|
|
group: {{ consul.group }}
|
2016-04-22 06:40:14 -04:00
|
|
|
- mode: 0644
|
2016-10-24 06:43:23 -04:00
|
|
|
{%- elif salt['test.provider']('service') == 'upstart' %}
|
2016-10-31 16:30:48 -04:00
|
|
|
- source: salt://{{ slspath }}/files/consul.upstart
|
2015-10-22 15:29:19 -04:00
|
|
|
- name: /etc/init/consul.conf
|
|
|
|
- mode: 0644
|
2016-10-24 06:43:23 -04:00
|
|
|
{%- else %}
|
2016-10-31 16:30:48 -04:00
|
|
|
- source: salt://{{ slspath }}/files/consul.sysvinit
|
2015-10-22 15:29:19 -04:00
|
|
|
- name: /etc/init.d/consul
|
|
|
|
- mode: 0755
|
2016-10-24 06:43:23 -04:00
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
{%- if consul.service %}
|
2015-10-22 15:29:19 -04:00
|
|
|
|
|
|
|
consul-service:
|
|
|
|
service.running:
|
|
|
|
- name: consul
|
2016-10-24 06:43:23 -04:00
|
|
|
- enable: True
|
|
|
|
- watch:
|
2017-11-28 05:16:19 -05:00
|
|
|
- file: consul-init-env
|
2016-10-24 06:43:23 -04:00
|
|
|
- file: consul-init-file
|
|
|
|
|
|
|
|
{%- endif %}
|