formula-consul/consul/install.sls

75 lines
1.8 KiB
Text
Raw Normal View History

2016-10-31 16:30:48 -04: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
consul-group:
2015-10-22 15:29:19 -04:00
group.present:
- name: {{ consul.group }}
consul-user:
user.present:
- name: {{ consul.user }}
- gid: {{ consul.group }}
- createhome: False
- system: True
2015-10-22 15:29:19 -04:00
- require:
- group: consul-group
2015-10-22 15:29:19 -04:00
# Create directories
consul-config-dir:
file.directory:
- name: /etc/consul.d
- user: {{ consul.user }}
- group: {{ consul.group }}
2015-10-22 15:29:19 -04:00
consul-data-dir:
file.directory:
- name: {{ consul.config.data_dir }}
2015-10-22 15:29:19 -04:00
- user: consul
- group: consul
- makedirs: True
2015-10-22 15:29:19 -04:00
# Install agent
consul-download:
file.managed:
- 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:
- 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:
- 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