2017-11-28 08:32:05 -05:00
|
|
|
{%- from slspath + '/map.jinja' import consul with context -%}
|
2015-10-22 15:29:19 -04:00
|
|
|
|
2016-04-08 06:35:36 -04:00
|
|
|
consul-dep-unzip:
|
|
|
|
pkg.installed:
|
|
|
|
- name: unzip
|
2015-10-22 15:29:19 -04:00
|
|
|
|
2016-04-08 06:35:36 -04:00
|
|
|
consul-bin-dir:
|
2015-10-22 15:29:19 -04:00
|
|
|
file.directory:
|
2019-01-21 20:09:01 -05:00
|
|
|
- name: /opt/consul/bin
|
2015-10-22 15:29:19 -04:00
|
|
|
- makedirs: True
|
|
|
|
|
|
|
|
# Create consul user
|
2017-11-28 05:16:19 -05:00
|
|
|
consul-group:
|
2015-10-22 15:29:19 -04:00
|
|
|
group.present:
|
2017-11-28 05:16:19 -05:00
|
|
|
- name: {{ consul.group }}
|
2019-01-21 20:38:09 -05:00
|
|
|
- system: True
|
2017-11-28 05:16:19 -05:00
|
|
|
|
|
|
|
consul-user:
|
2016-11-10 12:35:09 -05:00
|
|
|
user.present:
|
2017-11-28 05:16:19 -05:00
|
|
|
- name: {{ consul.user }}
|
2017-11-28 08:32:05 -05:00
|
|
|
- groups:
|
|
|
|
- {{ consul.group }}
|
2017-11-30 05:51:17 -05:00
|
|
|
- home: {{ salt['user.info'](consul.user)['home']|default(consul.config.data_dir) }}
|
2017-11-28 05:16:19 -05:00
|
|
|
- createhome: False
|
|
|
|
- system: True
|
2015-10-22 15:29:19 -04:00
|
|
|
- require:
|
2017-11-28 05:16:19 -05:00
|
|
|
- group: consul-group
|
2015-10-22 15:29:19 -04:00
|
|
|
|
|
|
|
# Create directories
|
|
|
|
consul-config-dir:
|
|
|
|
file.directory:
|
|
|
|
- name: /etc/consul.d
|
2017-11-28 05:16:19 -05:00
|
|
|
- user: {{ consul.user }}
|
|
|
|
- group: {{ consul.group }}
|
2017-11-28 08:32:05 -05:00
|
|
|
- mode: 0750
|
2015-10-22 15:29:19 -04:00
|
|
|
|
|
|
|
consul-data-dir:
|
|
|
|
file.directory:
|
2016-11-10 12:35:09 -05:00
|
|
|
- name: {{ consul.config.data_dir }}
|
|
|
|
- makedirs: True
|
2017-11-28 08:32:05 -05:00
|
|
|
- user: {{ consul.user }}
|
|
|
|
- group: {{ consul.group }}
|
|
|
|
- mode: 0750
|
2016-04-22 06:40:14 -04:00
|
|
|
|
2015-10-22 15:29:19 -04:00
|
|
|
# Install agent
|
|
|
|
consul-download:
|
|
|
|
file.managed:
|
2017-04-04 17:31:13 -04:00
|
|
|
- name: /tmp/consul_{{ consul.version }}_linux_{{ consul.arch }}.zip
|
|
|
|
- source: https://{{ consul.download_host }}/consul/{{ consul.version }}/consul_{{ consul.version }}_linux_{{ consul.arch }}.zip
|
|
|
|
- source_hash: https://releases.hashicorp.com/consul/{{ consul.version }}/consul_{{ consul.version }}_SHA256SUMS
|
2019-01-21 20:09:01 -05:00
|
|
|
- unless: test -f /opt/consul/bin/consul-{{ consul.version }}
|
2015-10-22 15:29:19 -04:00
|
|
|
|
|
|
|
consul-extract:
|
|
|
|
cmd.wait:
|
2017-04-04 17:31:13 -04:00
|
|
|
- name: unzip /tmp/consul_{{ consul.version }}_linux_{{ consul.arch }}.zip -d /tmp
|
2015-10-22 15:29:19 -04:00
|
|
|
- watch:
|
|
|
|
- file: consul-download
|
|
|
|
|
|
|
|
consul-install:
|
|
|
|
file.rename:
|
2019-01-21 20:09:01 -05:00
|
|
|
- name: /opt/consul/bin/consul-{{ consul.version }}
|
2015-10-22 15:29:19 -04:00
|
|
|
- source: /tmp/consul
|
|
|
|
- require:
|
2019-01-21 20:09:01 -05:00
|
|
|
- file: /opt/consul/bin
|
2015-10-22 15:29:19 -04:00
|
|
|
- watch:
|
|
|
|
- cmd: consul-extract
|
|
|
|
|
|
|
|
consul-clean:
|
|
|
|
file.absent:
|
2017-04-04 17:31:13 -04:00
|
|
|
- name: /tmp/consul_{{ consul.version }}_linux_{{ consul.arch }}.zip
|
2015-10-22 15:29:19 -04:00
|
|
|
- watch:
|
|
|
|
- file: consul-install
|
|
|
|
|
|
|
|
consul-link:
|
|
|
|
file.symlink:
|
|
|
|
- target: consul-{{ consul.version }}
|
2019-01-21 20:09:01 -05:00
|
|
|
- name: /opt/consul/bin/consul
|
2015-10-22 15:29:19 -04:00
|
|
|
- watch:
|
|
|
|
- file: consul-install
|