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:
|
2016-04-08 06:35:36 -04:00
|
|
|
- name: /usr/local/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 }}
|
|
|
|
|
|
|
|
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-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
|
2015-10-22 15:29:19 -04:00
|
|
|
- unless: test -f /usr/local/bin/consul-{{ consul.version }}
|
|
|
|
|
|
|
|
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:
|
|
|
|
- name: /usr/local/bin/consul-{{ consul.version }}
|
|
|
|
- source: /tmp/consul
|
|
|
|
- require:
|
|
|
|
- file: /usr/local/bin
|
|
|
|
- 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 }}
|
|
|
|
- name: /usr/local/bin/consul
|
|
|
|
- watch:
|
|
|
|
- file: consul-install
|